Hi, I'm running ty on a project that uses Oxyde ORM and hitting two categories of false positives that trace back to Oxyde's type signatures. Verified the same errors appear with pyright, so this isn't checker-specific.
Field() return type causes invalid-assignment
Model definitions like this:
class Session(Model):
id: str = Field(db_pk=True)
name: str = Field(default="")
get flagged because Field() returns OxydeFieldInfo at runtime, but the annotation says str. The checker sees str = OxydeFieldInfo(...) and reports an assignment type mismatch.
It affects every model field that uses Field(), so it's pretty noisy (48 errors in my project).
Stub generator skips module-level functions
A minor issue but I happen to have a few module-level async helper functions defined in models.py (not methods on a Model class). The stub generator doesn't pick these up, so any file importing them gets unresolved-import. Patching the generated .pyi manually isn't ideal.
Workaround
For now I'm suppressing the check in pyproject.toml:
[tool.ty.rules]
invalid-assignment = "ignore"
This works but it's global, which is less than ideal since it also hides real assignment errors in my own code...
Environment
- Oxyde: 0.5.2
- Oxyde-core: 0.4.3
- Python: 3.12
- Ty: 0.0.21
Thank you, really enjoying Oxyde so far!
Hi, I'm running ty on a project that uses Oxyde ORM and hitting two categories of false positives that trace back to Oxyde's type signatures. Verified the same errors appear with pyright, so this isn't checker-specific.
Field()return type causesinvalid-assignmentModel definitions like this:
get flagged because
Field()returnsOxydeFieldInfoat runtime, but the annotation saysstr. The checker seesstr = OxydeFieldInfo(...)and reports an assignment type mismatch.It affects every model field that uses
Field(), so it's pretty noisy (48 errors in my project).Stub generator skips module-level functions
A minor issue but I happen to have a few module-level async helper functions defined in
models.py(not methods on a Model class). The stub generator doesn't pick these up, so any file importing them getsunresolved-import. Patching the generated.pyimanually isn't ideal.Workaround
For now I'm suppressing the check in
pyproject.toml:This works but it's global, which is less than ideal since it also hides real assignment errors in my own code...
Environment
Thank you, really enjoying Oxyde so far!