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 F821 regression for classes marked as runtime-required #10511

Closed
wants to merge 1 commit into from

Conversation

AlexWaygood
Copy link
Member

Fixes #10451. This is basically a revert of 704fefc, but includes a more principled fix for the issue that that PR was trying to fix (#10362)

@AlexWaygood AlexWaygood added the bug Something isn't working label Mar 21, 2024
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

ℹ️ ecosystem check detected linter changes. (+97 -24 violations, +0 -0 fixes in 5 projects; 38 projects unchanged)

apache/airflow (+1 -23 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

- airflow/api_internal/endpoints/rpc_api_endpoint.py:58:9: SLF001 Private member accessed: `_add_to_db`
- airflow/api_internal/endpoints/rpc_api_endpoint.py:59:9: SLF001 Private member accessed: `_fetch_from_db`
- airflow/api_internal/endpoints/rpc_api_endpoint.py:60:9: SLF001 Private member accessed: `_kill`
- airflow/api_internal/endpoints/rpc_api_endpoint.py:61:9: SLF001 Private member accessed: `_update_heartbeat`
- airflow/api_internal/endpoints/rpc_api_endpoint.py:62:9: SLF001 Private member accessed: `_update_in_db`
- airflow/api_internal/endpoints/rpc_api_endpoint.py:64:9: SLF001 Private member accessed: `_fetch_connection`
... 18 additional changes omitted for rule SLF001
+ airflow/providers/amazon/aws/operators/appflow.py:486:13: UP037 [*] Remove quotes from type annotation
... 17 additional changes omitted for project

bokeh/bokeh (+7 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

+ src/bokeh/colors/color.py:52:35: UP037 [*] Remove quotes from type annotation
+ src/bokeh/core/query.py:58:48: UP037 [*] Remove quotes from type annotation
+ src/bokeh/core/serialization.py:186:37: UP037 [*] Remove quotes from type annotation
+ src/bokeh/core/serialization.py:187:40: UP037 [*] Remove quotes from type annotation
+ src/bokeh/core/types.py:56:34: UP037 [*] Remove quotes from type annotation
+ tests/support/util/examples.py:60:41: UP037 [*] Remove quotes from type annotation
+ tests/support/util/examples.py:60:61: UP037 [*] Remove quotes from type annotation

ibis-project/ibis (+2 -0 violations, +0 -0 fixes)

+ ibis/common/typing.py:22:54: UP037 [*] Remove quotes from type annotation
+ ibis/common/typing.py:27:47: UP037 [*] Remove quotes from type annotation

python/mypy (+7 -0 violations, +0 -0 fixes)

+ mypy/build.py:121:31: F821 Undefined name `State`
+ mypy/nodes.py:265:37: F821 Undefined name `SymbolTableNode`
+ mypy/nodes.py:265:63: F821 Undefined name `TypeInfo`
+ mypy/nodes.py:548:34: F821 Undefined name `FuncDef`
+ mypy/nodes.py:548:43: F821 Undefined name `Decorator`
+ mypy/server/astdiff.py:117:51: F821 Undefined name `SnapshotItem`
+ mypy/subtypes.py:77:69: F821 Undefined name `SubtypeContext`

zulip/zulip (+80 -1 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --no-preview --select ALL

+ analytics/lib/counts.py:376:32: FA100 Missing `from __future__ import annotations`, but uses `typing.Dict`
+ analytics/management/commands/populate_analytics_db.py:153:42: FA100 Missing `from __future__ import annotations`, but uses `typing.Union`
+ analytics/management/commands/populate_analytics_db.py:153:65: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
+ analytics/views/stats.py:262:28: FA100 Missing `from __future__ import annotations`, but uses `typing.Union`
+ analytics/views/stats.py:263:9: FA100 Missing `from __future__ import annotations`, but uses `typing.Type`
+ analytics/views/stats.py:264:9: FA100 Missing `from __future__ import annotations`, but uses `typing.Type`
+ analytics/views/stats.py:265:9: FA100 Missing `from __future__ import annotations`, but uses `typing.Type`
+ analytics/views/stats.py:266:9: FA100 Missing `from __future__ import annotations`, but uses `typing.Type`
+ confirmation/models.py:65:41: FA100 Missing `from __future__ import annotations`, but uses `typing.Union`
+ zerver/actions/streams.py:702:19: FA100 Missing `from __future__ import annotations`, but uses `typing.Tuple`
+ zerver/actions/streams.py:702:25: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
+ zerver/actions/streams.py:702:40: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
+ zerver/actions/streams.py:889:29: FA100 Missing `from __future__ import annotations`, but uses `typing.Tuple`
+ zerver/actions/streams.py:890:10: FA100 Missing `from __future__ import annotations`, but uses `typing.Tuple`
+ zerver/actions/streams.py:890:39: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
+ zerver/actions/streams.py:890:44: FA100 Missing `from __future__ import annotations`, but uses `typing.Tuple`
+ zerver/actions/streams.py:890:5: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
... 64 additional changes omitted for rule FA100
- zerver/lib/queue.py:84:13: SLF001 Private member accessed: `_DEFAULT`
... 63 additional changes omitted for project

Changes by rule (4 rules affected)

code total + violation - violation + fix - fix
FA100 80 80 0 0 0
SLF001 24 0 24 0 0
UP037 10 10 0 0 0
F821 7 7 0 0 0

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+92 -28 violations, +0 -0 fixes in 6 projects; 37 projects unchanged)

apache/airflow (+1 -26 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

- airflow/api_internal/endpoints/rpc_api_endpoint.py:58:9: SLF001 Private member accessed: `_add_to_db`
- airflow/api_internal/endpoints/rpc_api_endpoint.py:59:9: SLF001 Private member accessed: `_fetch_from_db`
- airflow/api_internal/endpoints/rpc_api_endpoint.py:60:9: SLF001 Private member accessed: `_kill`
- airflow/api_internal/endpoints/rpc_api_endpoint.py:61:9: SLF001 Private member accessed: `_update_heartbeat`
- airflow/api_internal/endpoints/rpc_api_endpoint.py:62:9: SLF001 Private member accessed: `_update_in_db`
- airflow/api_internal/endpoints/rpc_api_endpoint.py:64:9: SLF001 Private member accessed: `_fetch_connection`
... 18 additional changes omitted for rule SLF001
+ airflow/providers/amazon/aws/operators/appflow.py:486:13: UP037 [*] Remove quotes from type annotation
- airflow/providers/google/cloud/hooks/gcs.py:859:49: PLC2701 Private name import `_blobs_page_start` from external module `google.cloud.storage.bucket`
- airflow/providers/google/cloud/hooks/gcs.py:859:68: PLC2701 Private name import `_item_to_blob` from external module `google.cloud.storage.bucket`
- tests/providers/amazon/aws/utils/test_utils.py:22:5: PLC2701 Private name import `_StringCompareEnum` from external module `airflow.providers.amazon.aws.utils`
... 17 additional changes omitted for project

bokeh/bokeh (+7 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ src/bokeh/colors/color.py:52:35: UP037 [*] Remove quotes from type annotation
+ src/bokeh/core/query.py:58:48: UP037 [*] Remove quotes from type annotation
+ src/bokeh/core/serialization.py:186:37: UP037 [*] Remove quotes from type annotation
+ src/bokeh/core/serialization.py:187:40: UP037 [*] Remove quotes from type annotation
+ src/bokeh/core/types.py:56:34: UP037 [*] Remove quotes from type annotation
+ tests/support/util/examples.py:60:41: UP037 [*] Remove quotes from type annotation
+ tests/support/util/examples.py:60:61: UP037 [*] Remove quotes from type annotation

freedomofpress/securedrop (+0 -1 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

- securedrop/secure_tempfile.py:3:22: PLC2701 Private name import `_TemporaryFileWrapper` from external module `tempfile`

ibis-project/ibis (+2 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ ibis/common/typing.py:22:54: UP037 [*] Remove quotes from type annotation
+ ibis/common/typing.py:27:47: UP037 [*] Remove quotes from type annotation

python/mypy (+2 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview

+ mypy/build.py:121:31: F821 Undefined name `State`
+ mypy/subtypes.py:77:69: F821 Undefined name `SubtypeContext`

zulip/zulip (+80 -1 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ analytics/lib/counts.py:376:32: FA100 Missing `from __future__ import annotations`, but uses `typing.Dict`
+ analytics/management/commands/populate_analytics_db.py:153:42: FA100 Missing `from __future__ import annotations`, but uses `typing.Union`
+ analytics/management/commands/populate_analytics_db.py:153:65: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
+ analytics/views/stats.py:262:28: FA100 Missing `from __future__ import annotations`, but uses `typing.Union`
+ analytics/views/stats.py:263:9: FA100 Missing `from __future__ import annotations`, but uses `typing.Type`
+ analytics/views/stats.py:264:9: FA100 Missing `from __future__ import annotations`, but uses `typing.Type`
+ analytics/views/stats.py:265:9: FA100 Missing `from __future__ import annotations`, but uses `typing.Type`
+ analytics/views/stats.py:266:9: FA100 Missing `from __future__ import annotations`, but uses `typing.Type`
+ confirmation/models.py:65:41: FA100 Missing `from __future__ import annotations`, but uses `typing.Union`
+ zerver/actions/streams.py:702:19: FA100 Missing `from __future__ import annotations`, but uses `typing.Tuple`
+ zerver/actions/streams.py:702:25: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
+ zerver/actions/streams.py:702:40: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
+ zerver/actions/streams.py:889:29: FA100 Missing `from __future__ import annotations`, but uses `typing.Tuple`
+ zerver/actions/streams.py:890:10: FA100 Missing `from __future__ import annotations`, but uses `typing.Tuple`
+ zerver/actions/streams.py:890:39: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
+ zerver/actions/streams.py:890:44: FA100 Missing `from __future__ import annotations`, but uses `typing.Tuple`
+ zerver/actions/streams.py:890:5: FA100 Missing `from __future__ import annotations`, but uses `typing.List`
... 64 additional changes omitted for rule FA100
- zerver/lib/queue.py:84:13: SLF001 Private member accessed: `_DEFAULT`
... 63 additional changes omitted for project

Changes by rule (5 rules affected)

code total + violation - violation + fix - fix
FA100 80 80 0 0 0
SLF001 24 0 24 0 0
UP037 10 10 0 0 0
PLC2701 4 0 4 0 0
F821 2 2 0 0 0

@charliermarsh
Copy link
Member

I think this is not quite right but I haven't dug into why. It seems off to me that we have to set runtime_annotation in those various places here.

@AlexWaygood
Copy link
Member Author

Yeah, the ecosystem results indicate that this definitely is not quite right just yet :/

@charliermarsh
Copy link
Member

Let's start with a revert and revisit the fix itself.

@AlexWaygood
Copy link
Member Author

Sure, I'll do a revert PR now 👍

@AlexWaygood
Copy link
Member Author

#10513 to revert.

@AlexWaygood AlexWaygood marked this pull request as draft March 21, 2024 16:34
@AlexWaygood AlexWaygood deleted the pydantic-f821 branch March 21, 2024 16:59
@AlexWaygood
Copy link
Member Author

I'm still looking at this locally, but closing the PR for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

F821 false-positive for SQLAlchemy mappings with not yet declared classes
2 participants