Skip to content

gh-104683: Make Argument Clinic parser template strings class level members #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

erlend-aasland
Copy link

No description provided.

@erlend-aasland
Copy link
Author

What do you think of this? IMO, all these static strings pollute output_templates. I'm trying to improve the readability of that method.

@@ -873,44 +918,11 @@ def output_templates(
if new_or_init and not f.docstring:

Choose a reason for hiding this comment

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

There's a methoddef_define template string immediately above this line, should that also be moved into the class namespace?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, let's do that as well.

Copy link
Author

Choose a reason for hiding this comment

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

Copy link

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

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

Makes sense! You could annotate them with Final[str] to indicate to mypy that they're meant to be class-level "constants" that are never changed when accessed on the class or the instance -- they are set once, and then should be treated by the type checker as read-only after that

@erlend-aasland
Copy link
Author

Makes sense! You could annotate them with Final[str] to indicate to mypy that they're meant to be class-level "constants" that are never changed when accessed on the class or the instance -- they are set once, and then should be treated by the type checker as read-only after that

Neat!

@erlend-aasland
Copy link
Author

Opened python#107556

@erlend-aasland erlend-aasland deleted the clinic/prototypes branch August 2, 2023 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants