-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[flake8-pyi
] Implement PYI042
and PYI043
#4214
Conversation
PR Check ResultsEcosystemℹ️ ecosystem check detected changes. (+12, -0, 0 error(s)) typeshed (+12, -0)
+ stdlib/typing.pyi:735:1: PYI042 Type alias `_get_type_hints_obj_allowed_types` should be CamelCase
+ stubs/cffi/_cffi_backend.pyi:113:5: PYI042 Type alias `buffer` should be CamelCase
+ stubs/cffi/cffi/api.pyi:13:1: PYI042 Type alias `basestring` should be CamelCase
+ stubs/cffi/cffi/api.pyi:18:5: PYI042 Type alias `buffer` should be CamelCase
+ stubs/pika/pika/spec.pyi:9:1: PYI042 Type alias `_str` should be CamelCase
+ stubs/pywin32/pythoncom.pyi:10:1: PYI042 Type alias `error` should be CamelCase
+ stubs/pywin32/win32/odbc.pyi:9:1: PYI042 Type alias `_odbcError` should be CamelCase
+ stubs/pywin32/win32comext/adsi/adsi.pyi:7:1: PYI042 Type alias `error` should be CamelCase
+ stubs/pywin32/win32comext/propsys/propsys.pyi:6:1: PYI042 Type alias `error` should be CamelCase
+ stubs/pywin32/win32comext/shell/shell.pyi:7:1: PYI042 Type alias `error` should be CamelCase
+ stubs/redis/redis/typing.pyi:17:1: PYI043 Private type alias `_StringLikeT` should not be suffixed with `T` (the `T` suffix implies that an object is a `TypeVar`)
+ stubs/requests/requests/compat.pyi:22:1: PYI042 Type alias `builtin_str` should be CamelCase BenchmarkLinux
Windows
|
Hmm I'm not able to repro this test failure locally (macOS), when I run p.s. I'm pretty new to the ruff community: is it bad form to tag you like this? |
@arya-k - Not sure why I can't repro locally either, but I have a suspicion that we just hit a factor-of-two boundary and need to increase the Also: totally fine to tag me or other maintainers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution.
I think we should try to implement these rules without having to rely on regular expressions. Regular expressions are great but can be overkill when matching on simple patterns and using plain string methods can then be better for performance
...es/ruff/src/rules/flake8_pyi/snapshots/ruff__rules__flake8_pyi__tests__PYI042_PYI042.py.snap
Show resolved
Hide resolved
flake8-pyi
] Implement PYI042
and PYI043
Thank you for pushing this over the finish line- for my understanding, how did you format the python files? My installation of |
@arya-k - Oh interesting, I just ran Black from my own editor. |
I should correct that: we probably haven't run Black over all of our Python fixtures, so running |
Ah got it. I ran it on all fixtures, then figured it wasn’t the way we were formatting python. Thanks for the clarification! |
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://github.com/charliermarsh/ruff) | `^0.0.264` -> `^0.0.265` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.265`](https://github.com/charliermarsh/ruff/releases/tag/v0.0.265) [Compare Source](https://github.com/charliermarsh/ruff/compare/v0.0.264...v0.0.265) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed ##### Breaking Changes - Change `--fix-only` exit semantics to mirror `--fix` by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4146](https://github.com/charliermarsh/ruff/pull/4146) ##### Rules - \[flake8-pyi] PYI020 by [@​arya-k](https://github.com/arya-k) in [https://github.com/charliermarsh/ruff/pull/4211](https://github.com/charliermarsh/ruff/pull/4211) - Update B027 to support autofixing by [@​aacunningham](https://github.com/aacunningham) in [https://github.com/charliermarsh/ruff/pull/4178](https://github.com/charliermarsh/ruff/pull/4178) - \[`flake8-pyi`] Implement `PYI042` and `PYI043` by [@​arya-k](https://github.com/arya-k) in [https://github.com/charliermarsh/ruff/pull/4214](https://github.com/charliermarsh/ruff/pull/4214) - \[`pylint`] Implement import-self (`W0406`) by [@​chanman3388](https://github.com/chanman3388) in [https://github.com/charliermarsh/ruff/pull/4154](https://github.com/charliermarsh/ruff/pull/4154) - Warn on PEP 604 syntax not in an annotation, but don't autofix by [@​wookie184](https://github.com/wookie184) in [https://github.com/charliermarsh/ruff/pull/4170](https://github.com/charliermarsh/ruff/pull/4170) ##### Bug Fixes - Fix panic in pydocstyle D214 when docstring indentation is empty by [@​madkinsz](https://github.com/madkinsz) in [https://github.com/charliermarsh/ruff/pull/4216](https://github.com/charliermarsh/ruff/pull/4216) - Render tabs as 4 spaces in diagnostics by [@​MichaReiser](https://github.com/MichaReiser) in [https://github.com/charliermarsh/ruff/pull/4132](https://github.com/charliermarsh/ruff/pull/4132) - Fix era panic caused by out of bound edition by [@​leiserfg](https://github.com/leiserfg) in [https://github.com/charliermarsh/ruff/pull/4206](https://github.com/charliermarsh/ruff/pull/4206) - End of statement insertion should occur after newline by [@​dhruvmanila](https://github.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4215](https://github.com/charliermarsh/ruff/pull/4215) - Ignore **debuggerskip** in unused variable checks by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4229](https://github.com/charliermarsh/ruff/pull/4229) ##### CLI - Show settings path in `--show-settings` output by [@​dhruvmanila](https://github.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4199](https://github.com/charliermarsh/ruff/pull/4199) ##### Documentation - Allow linking to individual rules by [@​calumy](https://github.com/calumy) in [https://github.com/charliermarsh/ruff/pull/4158](https://github.com/charliermarsh/ruff/pull/4158) #### New Contributors - [@​wookie184](https://github.com/wookie184) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4170](https://github.com/charliermarsh/ruff/pull/4170) - [@​arya-k](https://github.com/arya-k) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4211](https://github.com/charliermarsh/ruff/pull/4211) **Full Changelog**: astral-sh/ruff@v0.0.264...v0.0.265 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/ixm-one/pytest-cmake-presets). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS43MS40IiwidXBkYXRlZEluVmVyIjoiMzUuNzEuNCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Signed-off-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://github.com/charliermarsh/ruff) | `==0.0.264` -> `==0.0.265` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.265`](https://github.com/charliermarsh/ruff/releases/tag/v0.0.265) [Compare Source](https://github.com/charliermarsh/ruff/compare/v0.0.264...v0.0.265) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed ##### Breaking Changes - Change `--fix-only` exit semantics to mirror `--fix` by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4146](https://github.com/charliermarsh/ruff/pull/4146) ##### Rules - \[flake8-pyi] PYI020 by [@​arya-k](https://github.com/arya-k) in [https://github.com/charliermarsh/ruff/pull/4211](https://github.com/charliermarsh/ruff/pull/4211) - Update B027 to support autofixing by [@​aacunningham](https://github.com/aacunningham) in [https://github.com/charliermarsh/ruff/pull/4178](https://github.com/charliermarsh/ruff/pull/4178) - \[`flake8-pyi`] Implement `PYI042` and `PYI043` by [@​arya-k](https://github.com/arya-k) in [https://github.com/charliermarsh/ruff/pull/4214](https://github.com/charliermarsh/ruff/pull/4214) - \[`pylint`] Implement import-self (`W0406`) by [@​chanman3388](https://github.com/chanman3388) in [https://github.com/charliermarsh/ruff/pull/4154](https://github.com/charliermarsh/ruff/pull/4154) - Warn on PEP 604 syntax not in an annotation, but don't autofix by [@​wookie184](https://github.com/wookie184) in [https://github.com/charliermarsh/ruff/pull/4170](https://github.com/charliermarsh/ruff/pull/4170) ##### Bug Fixes - Fix panic in pydocstyle D214 when docstring indentation is empty by [@​madkinsz](https://github.com/madkinsz) in [https://github.com/charliermarsh/ruff/pull/4216](https://github.com/charliermarsh/ruff/pull/4216) - Render tabs as 4 spaces in diagnostics by [@​MichaReiser](https://github.com/MichaReiser) in [https://github.com/charliermarsh/ruff/pull/4132](https://github.com/charliermarsh/ruff/pull/4132) - Fix era panic caused by out of bound edition by [@​leiserfg](https://github.com/leiserfg) in [https://github.com/charliermarsh/ruff/pull/4206](https://github.com/charliermarsh/ruff/pull/4206) - End of statement insertion should occur after newline by [@​dhruvmanila](https://github.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4215](https://github.com/charliermarsh/ruff/pull/4215) - Ignore **debuggerskip** in unused variable checks by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4229](https://github.com/charliermarsh/ruff/pull/4229) ##### CLI - Show settings path in `--show-settings` output by [@​dhruvmanila](https://github.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4199](https://github.com/charliermarsh/ruff/pull/4199) ##### Documentation - Allow linking to individual rules by [@​calumy](https://github.com/calumy) in [https://github.com/charliermarsh/ruff/pull/4158](https://github.com/charliermarsh/ruff/pull/4158) #### New Contributors - [@​wookie184](https://github.com/wookie184) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4170](https://github.com/charliermarsh/ruff/pull/4170) - [@​arya-k](https://github.com/arya-k) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4211](https://github.com/charliermarsh/ruff/pull/4211) **Full Changelog**: astral-sh/ruff@v0.0.264...v0.0.265 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/allenporter/flux-local). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS43MS40IiwidXBkYXRlZEluVmVyIjoiMzUuNzEuNCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://github.com/charliermarsh/ruff) | `==0.0.264` -> `==0.0.265` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.265`](https://github.com/charliermarsh/ruff/releases/tag/v0.0.265) [Compare Source](https://github.com/charliermarsh/ruff/compare/v0.0.264...v0.0.265) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed ##### Breaking Changes - Change `--fix-only` exit semantics to mirror `--fix` by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4146](https://github.com/charliermarsh/ruff/pull/4146) ##### Rules - \[flake8-pyi] PYI020 by [@​arya-k](https://github.com/arya-k) in [https://github.com/charliermarsh/ruff/pull/4211](https://github.com/charliermarsh/ruff/pull/4211) - Update B027 to support autofixing by [@​aacunningham](https://github.com/aacunningham) in [https://github.com/charliermarsh/ruff/pull/4178](https://github.com/charliermarsh/ruff/pull/4178) - \[`flake8-pyi`] Implement `PYI042` and `PYI043` by [@​arya-k](https://github.com/arya-k) in [https://github.com/charliermarsh/ruff/pull/4214](https://github.com/charliermarsh/ruff/pull/4214) - \[`pylint`] Implement import-self (`W0406`) by [@​chanman3388](https://github.com/chanman3388) in [https://github.com/charliermarsh/ruff/pull/4154](https://github.com/charliermarsh/ruff/pull/4154) - Warn on PEP 604 syntax not in an annotation, but don't autofix by [@​wookie184](https://github.com/wookie184) in [https://github.com/charliermarsh/ruff/pull/4170](https://github.com/charliermarsh/ruff/pull/4170) ##### Bug Fixes - Fix panic in pydocstyle D214 when docstring indentation is empty by [@​madkinsz](https://github.com/madkinsz) in [https://github.com/charliermarsh/ruff/pull/4216](https://github.com/charliermarsh/ruff/pull/4216) - Render tabs as 4 spaces in diagnostics by [@​MichaReiser](https://github.com/MichaReiser) in [https://github.com/charliermarsh/ruff/pull/4132](https://github.com/charliermarsh/ruff/pull/4132) - Fix era panic caused by out of bound edition by [@​leiserfg](https://github.com/leiserfg) in [https://github.com/charliermarsh/ruff/pull/4206](https://github.com/charliermarsh/ruff/pull/4206) - End of statement insertion should occur after newline by [@​dhruvmanila](https://github.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4215](https://github.com/charliermarsh/ruff/pull/4215) - Ignore **debuggerskip** in unused variable checks by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/4229](https://github.com/charliermarsh/ruff/pull/4229) ##### CLI - Show settings path in `--show-settings` output by [@​dhruvmanila](https://github.com/dhruvmanila) in [https://github.com/charliermarsh/ruff/pull/4199](https://github.com/charliermarsh/ruff/pull/4199) ##### Documentation - Allow linking to individual rules by [@​calumy](https://github.com/calumy) in [https://github.com/charliermarsh/ruff/pull/4158](https://github.com/charliermarsh/ruff/pull/4158) #### New Contributors - [@​wookie184](https://github.com/wookie184) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4170](https://github.com/charliermarsh/ruff/pull/4170) - [@​arya-k](https://github.com/arya-k) made their first contribution in [https://github.com/charliermarsh/ruff/pull/4211](https://github.com/charliermarsh/ruff/pull/4211) **Full Changelog**: astral-sh/ruff@v0.0.264...v0.0.265 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/allenporter/pyrainbird). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS43MS40IiwidXBkYXRlZEluVmVyIjoiMzUuNzEuNCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
PYI042 Type alias names should use CamelCase rather than snake_case
PYI043 Do not use names ending in "T" for private type aliases. (The "T" suffix implies that an object is a TypeVar.)
rel: #848