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 Y042: Enforce private names for type aliases #240

Closed
wants to merge 3 commits into from

Conversation

AlexWaygood
Copy link
Collaborator

Part of #238

@AlexWaygood
Copy link
Collaborator Author

AlexWaygood commented Jul 6, 2022

I'll look at the typeshed hits in a bit. It looks like there might be too many false positives for this to be merged (but also looks like there might be some true positives in there that should be fixed).

@AlexWaygood AlexWaygood marked this pull request as draft July 6, 2022 11:47
@srittau
Copy link
Collaborator

srittau commented Jul 6, 2022

I would put type aliases into a separate test. Type aliases are more likely to be exported than type vars and users might want to toggle this separately. Also it means we can add this test independently and disable it in typeshed, until fixed if necessary.

@AlexWaygood
Copy link
Collaborator Author

I would put type aliases into a separate test. Type aliases are more likely to be exported than type vars and users might want to toggle this separately. Also it means we can add this test independently and disable it in typeshed, until fixed if necessary.

That makes sense, I'll make the change

@AlexWaygood AlexWaygood changed the title Extend Y001 to cover type aliases Introduce Y042: Enforce private names for type aliases Jul 6, 2022
pyi.py Outdated Show resolved Hide resolved
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
@AlexWaygood
Copy link
Collaborator Author

AlexWaygood commented Jul 7, 2022

This uncovered a few genuine typeshed bugs (python/typeshed#8248 tackles some, but not all of them; there's more still to work through -- the full typeshed-primer run is at https://github.com/PyCQA/flake8-pyi/runs/7217799410?check_suite_focus=true). But I think there's too many false positives here for this to be mergeable. Ultimately the issue is that this pattern is fairly common in typeshed, if you have a class where the name changed between Python versions:

class _Foo: ...

if sys.version_info >= (3, 9):
    Foo: TypeAlias = _Foo
else:
    Bar: TypeAlias = _Foo

@AlexWaygood
Copy link
Collaborator Author

This uncovered a few genuine typeshed bugs (python/typeshed#8248 tackles some, but not all of them; there's more still to work through

python/typeshed#8252 fixed the other ones.

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