Skip to content
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

Introduce a check disallowing module-level defaults, and improve Y015 error messages #145

Closed
wants to merge 8 commits into from

Conversation

AlexWaygood
Copy link
Collaborator

Closes #98

@AlexWaygood
Copy link
Collaborator Author

That looks like more typeshed hits than I was hoping for, but haven't got time to check them out now; will do so later.

@AlexWaygood AlexWaygood marked this pull request as draft January 25, 2022 13:32
@AlexWaygood
Copy link
Collaborator Author

(I've found the bug in the PR, am working on a fix)

@AlexWaygood AlexWaygood changed the title Introduce a check disallowing module-level defaults, and improve detection of unused TypeVars Introduce a check disallowing module-level defaults Jan 25, 2022
@AlexWaygood
Copy link
Collaborator Author

Okay, I think this is ready for review now. Typeshed PR here: python/typeshed#7036

@AlexWaygood AlexWaygood marked this pull request as ready for review January 25, 2022 14:49
pyi.py Outdated Show resolved Hide resolved
pyi.py Outdated Show resolved Hide resolved
pyi.py Show resolved Hide resolved
README.rst Outdated Show resolved Hide resolved
tests/attribute_annotations.pyi Outdated Show resolved Hide resolved
AlexWaygood and others added 3 commits January 25, 2022 15:10
Co-authored-by: Akuli <akuviljanen17@gmail.com>
@AlexWaygood AlexWaygood changed the title Introduce a check disallowing module-level defaults Introduce a check disallowing module-level defaults, and improve Y015 error messages Jan 25, 2022

field0: int
field_foo: int = ... # Y032 Default value unnecessary. Use "field_foo: int" instead of "field_foo: int = ..."
field_bar: int = 0 # Y032 Default value unnecessary. Use "field_bar: int" instead of "field_bar: int = 0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like how this accounts for class members that just happen to use the same name. I find it confusing, and it seems like it will make refactoring stubs fragile and surprising.

Has anyone looked into disabling the flake8 undefined variable warning yet? Alternatively, would it be less work to not count instance attributes, argument names etc as using the global variable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, this bothers me too. I initially tried to work around it (see my first commit on this PR), but it was more complicated than I expected, so I gave up.

I have another idea for a fix, which I'll try tomorrow.

@AlexWaygood AlexWaygood marked this pull request as draft January 25, 2022 23:26
@AlexWaygood
Copy link
Collaborator Author

AlexWaygood commented Jan 26, 2022

I think this PR has lost its way a little bit. I'm going to close it, propose some of the ideas in chunks, and rethink some of the other ideas.

@AlexWaygood AlexWaygood deleted the default-values branch January 26, 2022 10:12
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.

Error for unnecessary "= ..."
2 participants