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

Fix false negatives in Y018/Y046/Y047/Y049 #384

Merged
merged 2 commits into from
May 16, 2023
Merged

Fix false negatives in Y018/Y046/Y047/Y049 #384

merged 2 commits into from
May 16, 2023

Conversation

AlexWaygood
Copy link
Collaborator

Fixes #383

@github-actions

This comment has been minimized.

@AlexWaygood
Copy link
Collaborator Author

⚠ Flake8 diff showing the effect of this PR on typeshed:

> ./stdlib/asyncio/__init__.pyi:39:5: Y047 Type alias "_AwaitableLike" is not used
> ./stdlib/asyncio/__init__.pyi:40:5: Y047 Type alias "_CoroutineLike" is not used

These are true positives: the aliases aren't used in that file: https://github.com/python/typeshed/blob/2d5dafadb75f122e0c2aeced09a5b72232373f40/stdlib/asyncio/__init__.pyi#L37-L43

@github-actions
Copy link

⚠ Flake8 diff showing the effect of this PR on typeshed:

> ./stdlib/asyncio/__init__.pyi:39:5: Y047 Type alias "_AwaitableLike" is not used
> ./stdlib/asyncio/__init__.pyi:40:5: Y047 Type alias "_CoroutineLike" is not used

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

I'm not a huge fan of defining field types in class scope, outside of their initialization. Feels not very Pythonic for me and duplicates code unnecessarily, but that's a personal preference, not a blocker.

@srittau srittau merged commit 9bff389 into main May 16, 2023
@srittau srittau deleted the y047 branch May 16, 2023 09:20
@AlexWaygood
Copy link
Collaborator Author

I'm not a huge fan of defining field types in class scope, outside of their initialization. Feels not very Pythonic for me and duplicates code unnecessarily, but that's a personal preference, not a blocker.

I know what you mean. The reason I went this way was that the defaultdict annotations were getting too cumbersome otherwise. I couldn't stomach the idea of doing this five times in one __init__ method:

self.typevarlike_defs: defaultdict[TypeVarInfo, list[ast.Assign]]
self.typevarlike_defs = defaultdict(list)

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.

Y047 false negative for conditionally defined aliases
2 participants