FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-104050: Argument clinic: Add annotations to the `LandMine` class by AlexWaygood · Pull Request #104648 · python/cpython · GitHub

/ cpython Public

gh-104050: Argument clinic: Add annotations to the LandMine class - #104648

Closed
AlexWaygood wants to merge 2 commits into
python:mainfrom
AlexWaygood:argclinic-getattrs
Closed

gh-104050: Argument clinic: Add annotations to the LandMine class#104648
AlexWaygood wants to merge 2 commits into
python:mainfrom
AlexWaygood:argclinic-getattrs

Conversation

AlexWaygood commented May 19, 2023
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

When type checkers see that a class has a __getattr__ or __getattribute__ method, they'll assume that there are things going on with that class that are too magical for them to understand. As such, they will refrain from emitting any errors relating to setting or retrieving attributes from instances of that class. That's basically the opposite of what we want here (there'll be a runtime exception from any attribute access on an instance of LandMine). As such, it's much better to pretend to the type checkers that the __getattribute__ method doesn't exist.

sobolevn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes, good hack!

AlexWaygood commented May 21, 2023
edited
Loading

Copy link
Copy Markdown
Member Author

This is the best thing to do if we want to have strict typing in clinic.py, but I wonder if we do? The original motivation for adding type hints was to improve maintainability and readability, and this change possibly works against that. The original justification for running a type checker in CI was to have a means of verifying the accuracy of the annotations we were adding, not necessarily because we wanted the code to be strictly type-checked.

Thoughts @erlend-aasland? I don't want to be introducing "typing hacks" into clinic.py if you disagree with the principle :)

Copy link
Copy Markdown
Contributor

Strict type-checking is not a goal at the moment. I agree that this does not contribute to increased readability, so I say we drop it.

Copy link
Copy Markdown
Member Author

Strict type-checking is not a goal at the moment. I agree that this does not contribute to increased readability, so I say we drop it.

Sounds good. Thanks!

AlexWaygood deleted the argclinic-getattrs branch May 21, 2023 08:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL