-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
F821 false-positive for SQLAlchemy mappings with not yet declared classes #10451
Comments
Hi! I can't reproduce your error locally or in the Ruff playground: https://play.ruff.rs/1f9ab24b-394d-46c3-923a-ecf866705693 Can you paste a snippet that reproduces the error in the Ruff playground? |
Does the playground have a real installation of I can only reproduce it locally with the actual |
I don't think it should matter from Ruff's perspective whether |
I can't reproduce locally with SQLAlchemy installed either. Does it still reproduce for you after running |
We are also hitting this issue in this project: https://github.com/arista-netdevops-community/anta If you install the project locally with 0.3.3 you should see a bunch of F821 errors: (.anta-dev) ~/git_projects/anta (main ✗) ruff check
anta/models.py:273:27: F821 Undefined name `ResultOverwrite`
anta/models.py:274:18: F821 Undefined name `Filters`
anta/tests/bfd.py:40:25: F821 Undefined name `BFDPeer`
anta/tests/bfd.py:93:25: F821 Undefined name `BFDPeer`
anta/tests/connectivity.py:35:21: F821 Undefined name `Host`
anta/tests/connectivity.py:94:25: F821 Undefined name `Neighbor`
anta/tests/interfaces.py:176:26: F821 Undefined name `InterfaceState`
anta/tests/interfaces.py:535:26: F821 Undefined name `InterfaceDetail`
anta/tests/routing/bgp.py:175:32: F821 Undefined name `BgpAfi`
anta/tests/routing/bgp.py:285:32: F821 Undefined name `BgpAfi`
anta/tests/routing/bgp.py:397:32: F821 Undefined name `BgpAfi`
anta/tests/routing/bgp.py:509:25: F821 Undefined name `BgpNeighbor`
anta/tests/routing/bgp.py:581:25: F821 Undefined name `BgpPeer`
anta/tests/routing/bgp.py:653:25: F821 Undefined name `BgpPeer`
anta/tests/routing/bgp.py:719:25: F821 Undefined name `BgpPeer`
anta/tests/routing/bgp.py:785:25: F821 Undefined name `BgpPeer`
anta/tests/routing/bgp.py:846:31: F821 Undefined name `VxlanEndpoint`
anta/tests/routing/bgp.py:909:25: F821 Undefined name `BgpPeer`
anta/tests/routing/bgp.py:968:25: F821 Undefined name `BgpPeer`
anta/tests/security.py:303:28: F821 Undefined name `APISSLCertificate`
anta/tests/security.py:462:33: F821 Undefined name `IPv4ACL`
anta/tests/security.py:471:27: F821 Undefined name `IPv4ACLEntry`
anta/tests/services.py:106:27: F821 Undefined name `DnsServer`
anta/tests/services.py:159:23: F821 Undefined name `ErrDisableReason`
Found 24 errors. Thanks |
I also can't reproduce this in the playground, but I can reproduce by running |
(I can't reproduce by running locally over the originating snippet.) |
This reproduces: from __future__ import annotations
from pydantic import BaseModel
class Input(BaseModel):
result_overwrite: ResultOverwrite | None = None
filters: Filters | None = None
class ResultOverwrite(BaseModel):
...
class Filters(BaseModel):
... |
The original snippet doesn't reproduce because |
Okay, so |
Should I open a separate issue to track it? |
@carl-baillargeon Should be the same issue due to |
Confirmed that this (unsurprisingly) bisects to 704fefc. Sorry for the regression! |
Confirmed. |
The described behavior happens since 0.3.3. It might be related to #10340
It is triggered throughout my SQLAlchemy models in cases where a model is not defined yet while used in a type annotation
Minimal repro:
I can only trigger the error when inheriting from
DeclarativeBase
. Without this inheritance or when inheriting from another class, things are fine.The text was updated successfully, but these errors were encountered: