Detect duplicate branch definitions#543
Open
JelleZijlstra wants to merge 2 commits into
Open
Conversation
This comment has been minimized.
This comment has been minimized.
|
⚠ Flake8 diff showing the effect of this PR on typeshed: > ./stdlib/ast.pyi:769:9: Y069 Definition "__init__" is identical in multiple sys.version_info/sys.platform branches
> ./stdlib/pathlib/__init__.pyi:158:9: Y069 Definition "__new__" is identical in multiple sys.version_info/sys.platform branches
> ./stdlib/sysconfig.pyi:52:5: Y069 Definition "is_python_build" is identical in multiple sys.version_info/sys.platform branches
> ./stdlib/tkinter/__init__.pyi:792:9: Y069 Definition "wm_attributes" is identical in multiple sys.version_info/sys.platform branches
> ./stdlib/tkinter/__init__.pyi:823:13: Y069 Definition "wm_attributes" is identical in multiple sys.version_info/sys.platform branches
> ./stubs/pyinstaller/PyInstaller/building/api.pyi:33:5: Y069 Definition "_IconParam" is identical in multiple sys.version_info/sys.platform branches |
Member
|
While I think this is useful to run from time to time, considering the substantial amount of false positives, I suggest to move this to the "not enabled by default" section of error codes. |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Y069 to flag definitions that are identical across sibling
sys.version_infoorsys.platformbranches. Non-consecutive duplicates in 3+-branch version chains are ignored so newest-first ordering can be preserved.Some known issues in typeshed are fixed in python/typeshed#15743.
Remaining typeshed hits from this check:
stdlib/ast.pyi:769 - overlappingImportFrom.__init__overload shared by adjacent version branches. Deduplicating this would probably make the code harder to follow.stdlib/pathlib/__init__.pyi:160 -Path.__new__is identical except for a pyright ignore comment, which is ignored by AST comparison.stdlib/tkinter/__init__.pyi:791,stdlib/tkinter/__init__.pyi:822 - wm_attributes platform overload sets partially overlap. Hard to fix without making the code harder to followstubs/pyinstaller/PyInstaller/building/api.pyi:33 - _IconParam is the same for win32 and darwin while _Icon differs.This found a few useful things, but also has false positives. It may be worth doing to protect against issues in future PRs, but curious to hear other opinions.