-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Union not being recognized as types.UnionType #13810
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
Labels
bug
mypy got something wrong
topic-pep-604
PEP 604 (union | operator)
topic-runtime-semantics
mypy doesn't model runtime semantics correctly
Comments
karthiknadig
pushed a commit
to microsoft/lsprotocol
that referenced
this issue
Oct 26, 2022
picking off quite a few typechecking errors. Some remarks - I haven't committed the re-generated code - when I regenerate, several hooks go missing (the same happens on main) - perhaps you have a set of manual changes that you apply to the autogenerated code? - I believe that `enable_recursive_aliases` will soon be mypy default, so that seems a very reasonable thing to include - I haven't added `py.typed`, or tried to update your github workflow to run mypy - you'll want to do both of those I think: so that others can take advantage of these types, and so that they don't regress remaining errors are as follows: ``` lsprotocol/types.py:5136: error: Name "kind" already defined on line 5130 [no-redef] lsprotocol/types.py:5162: error: Name "kind" already defined on line 5153 [no-redef] lsprotocol/types.py:5185: error: Name "kind" already defined on line 5179 [no-redef] lsprotocol/types.py:12070: error: Dict entry 82 has incompatible type "str": "object"; expected "str": "type" [dict-item] lsprotocol/types.py:12076: error: Dict entry 88 has incompatible type "str": "object"; expected "str": "type" [dict-item] lsprotocol/types.py:12114: error: Dict entry 126 has incompatible type "str": "object"; expected "str": "type" [dict-item] lsprotocol/types.py:12116: error: Dict entry 128 has incompatible type "str": "object"; expected "str": "type" [dict-item] lsprotocol/types.py:12183: error: Dict entry 195 has incompatible type "str": "object"; expected "str": "type" [dict-item] lsprotocol/types.py:12213: error: Dict entry 225 has incompatible type "str": "object"; expected "str": "type" [dict-item] lsprotocol/types.py:12226: error: Dict entry 238 has incompatible type "str": "object"; expected "str": "type" [dict-item] lsprotocol/types.py:12241: error: Dict entry 253 has incompatible type "str": "object"; expected "str": "type" [dict-item] lsprotocol/types.py:12268: error: Dict entry 280 has incompatible type "str": "object"; expected "str": "type" [dict-item] lsprotocol/types.py:12291: error: Dict entry 303 has incompatible type "str": "object"; expected "str": "type" [dict-item] lsprotocol/types.py:12298: error: Dict entry 310 has incompatible type "str": "object"; expected "str": "type" [dict-item] lsprotocol/types.py:12389: error: Dict entry 401 has incompatible type "str": "object"; expected "str": "type" [dict-item] lsprotocol/types.py:12411: error: Dict entry 423 has incompatible type "str": "object"; expected "str": "type" [dict-item] lsprotocol/types.py:12534: error: Dict entry 546 has incompatible type "str": "object"; expected "str": "type" [dict-item] lsprotocol/converters.py:122: error: Name "LSPAny" is not defined [name-defined] ``` where - the first group look to me as though they might represent a real bug, probably you should look into that - the second group are I think a mypy error, possibly python/mypy#13810 or similar - probably these just want ignoring? - the final one would be easy to fix - use `lsp_types.LSPAny` - but doing that for some reason causes test breakage - seems like there's something screwy here, again you might want to look into it - though perhaps the unusual treatment of `"LspAny"` in this piece of code suggests you already know that something's up
Fixed by #17371 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
mypy got something wrong
topic-pep-604
PEP 604 (union | operator)
topic-runtime-semantics
mypy doesn't model runtime semantics correctly
In this example,
mypy (0.990, Python 3.10.6) reveals the type as
builtins.object
. It should be recognized astypes.UnionType
(new in Python 3.10).The text was updated successfully, but these errors were encountered: