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

Ignore underscore references in type annotations #9036

Merged
merged 1 commit into from Dec 7, 2023
Merged

Conversation

charliermarsh
Copy link
Member

Summary

Occasionally, valid code needs to use argparse._SubParsersAction in a type annotation. This isn't great, but it's indicative of the fact that public interfaces can return private types. If you accessed that private type via a private interface, then we should be flagging the call site, rather than the annotation.

Closes #9013.

Copy link
Contributor

github-actions bot commented Dec 7, 2023

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+0 -8 violations, +0 -0 fixes in 41 projects)

apache/airflow (+0 -6 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --no-preview --select ALL

- airflow/cli/cli_parser.py:159:30: SLF001 Private member accessed: `_SubParsersAction`
- airflow/providers/cncf/kubernetes/utils/k8s_hashlib_wrapper.py:32:44: SLF001 Private member accessed: `_Hash`
- airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py:151:35: SLF001 Private member accessed: `_ParameterSpec`
- airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py:73:35: SLF001 Private member accessed: `_ParameterSpec`
- airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py:154:35: SLF001 Private member accessed: `_ParameterSpec`
- airflow/utils/hashlib_wrapper.py:29:44: SLF001 Private member accessed: `_Hash`

zulip/zulip (+0 -2 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --no-preview --select ALL

- zerver/lib/queue.py:84:18: SLF001 Private member accessed: `_DEFAULT`
- zerver/lib/request.py:295:20: SLF001 Private member accessed: `_NotSpecified`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
SLF001 8 0 8 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+0 -8 violations, +0 -0 fixes in 41 projects)

apache/airflow (+0 -6 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview --select ALL

- airflow/cli/cli_parser.py:159:30: SLF001 Private member accessed: `_SubParsersAction`
- airflow/providers/cncf/kubernetes/utils/k8s_hashlib_wrapper.py:32:44: SLF001 Private member accessed: `_Hash`
- airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py:151:35: SLF001 Private member accessed: `_ParameterSpec`
- airflow/providers/google/cloud/hooks/vertex_ai/hyperparameter_tuning_job.py:73:35: SLF001 Private member accessed: `_ParameterSpec`
- airflow/providers/google/cloud/operators/vertex_ai/hyperparameter_tuning_job.py:154:35: SLF001 Private member accessed: `_ParameterSpec`
- airflow/utils/hashlib_wrapper.py:29:44: SLF001 Private member accessed: `_Hash`

zulip/zulip (+0 -2 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --preview --select ALL

- zerver/lib/queue.py:84:18: SLF001 Private member accessed: `_DEFAULT`
- zerver/lib/request.py:295:20: SLF001 Private member accessed: `_NotSpecified`

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
SLF001 8 0 8 0 0

@charliermarsh charliermarsh marked this pull request as ready for review December 7, 2023 03:05
@charliermarsh charliermarsh merged commit bbb0a0c into main Dec 7, 2023
17 checks passed
@charliermarsh charliermarsh deleted the charlie/slf branch December 7, 2023 03:05
@charliermarsh
Copy link
Member Author

I like what I see in the ecosystem changes -- it's having the intended effect, and those are more cases in which the underscore access is valid.

@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SLF001 and type annotations
1 participant