Open febus982 opened 2 weeks ago
Thanks @febus982 for reporting this issue. we will try to fix the problem.
I get the same 'error: X | Y syntax for unions requires Python 3.10 [syntax]' for the following file:
import pydantic_settings
class Temp(pydantic_settings.BaseSettings):
pass
I'm pretty sure there's no '|' in there. 😃 Some versions: mypy=1.11.1 pydantic=2.8.2 pydantic-core=2.20.1 pydantic-settings=2.5.2
What's really strange is that I do not get the error in the CI-pipeline, which uses the exact same versions. I deleted the .mypy_cache folder multiple times but the error persists.
Bug Report
mypy identifies false positive
X | Y
errors on not existing lines ifpydantic.mypy
plugin is enabled.Note that I cannot find any instance of
X | Y
in the whole repository.To Reproduce
This is the file: https://github.com/febus982/bootstrap-python-fastapi/blob/main/src/bootstrap/config.py
Command used:
mypy --python-version 3.9 --no-incremental
from the root repository directory.Expected Behavior
No errors reported
Actual Behavior
Note that the
src/bootstrap/config.py
file is only 64 lines longYour Environment
mypy 1.11.2 (compiled: yes)
--python-version 3.9
(also--no-incremental
to show line numbers but the error persists without)mypy.ini
(and other config files): from pyproject.tomlWe can remove celery by installing
celery-types
but needsat least python 3.10. For now we maintain the override.
[[tool.mypy.overrides]] module = [ "celery.*" ] ignore_missing_imports = true