I started encountering this when updating https://github.com/python-trio/flake8-trio - but it's been 9 months since last time I ran the type tests so it'd be a pain to figure out when exactly it started happening. If needed I can try to binary search for it though, and/or figure out if it's an update in pyright or libcst that messed it up.
$ mypy foo.py
foo.py:8: note: Revealed type is "libcst._position.CodeRange"
Success: no issues found in 1 source file
but pyright gives an additional weird union
$ pyright foo.py
/tmp/pyright+libcst/foo.py
/tmp/pyright+libcst/foo.py:8:21 - information: Type of "metadata" is "CodeRange | type[_UNDEFINED_DEFAULT]"
0 errors, 0 warnings, 1 information
I started encountering this when updating https://github.com/python-trio/flake8-trio - but it's been 9 months since last time I ran the type tests so it'd be a pain to figure out when exactly it started happening. If needed I can try to binary search for it though, and/or figure out if it's an update in pyright or libcst that messed it up.
repro
foo.py:
Works in mypy
but pyright gives an additional weird union
versions
real-life code
https://github.com/python-trio/flake8-trio/blob/dde4479842315a6a64f2f56d3875931ead9f0af3/flake8_trio/visitors/visitor_utility.py#L183