Repository navigation
Conversation
This comment has been minimized.
This comment has been minimized.
|
As you can see from Consider using |
|
Just found #3902. It's about |
|
LGTM, but I'd like to get the opinion of another maintainer too. |
|
Changed to Anyways, at least I'd prefer false positives over false negatives, so I'd be happy with |
|
There is a subtle difference: if you do something with |
|
👍 Thanks for the clafification and quick review! |
|
As a side note, it seems like |
|
Diff from mypy_primer, showing the effect of this PR on open source code: sphinx (https://github.com/sphinx-doc/sphinx.git)
+ sphinx/ext/autodoc/__init__.py: note: In member "parse_name" of class "Documenter":
+ sphinx/ext/autodoc/__init__.py:405:23: error: Need type annotation for "parents"
poetry (https://github.com/python-poetry/poetry.git)
- poetry/installation/chooser.py:156: error: Incompatible types in assignment (expression has type "Tuple[int, Union[str, Any]]", variable has type "Tuple[]")
+ poetry/installation/chooser.py:156: error: Incompatible types in assignment (expression has type "Tuple[int, Union[Any, str]]", variable has type "Tuple[]")
aiohttp (https://github.com/aio-libs/aiohttp.git)
+ aiohttp/client_reqrep.py:809: error: unused "type: ignore" comment
+ aiohttp/client_reqrep.py:813: error: Argument 1 to "add" of "MultiDict" has incompatible type "Union[str, URL, Any]"; expected "Union[str, istr]" [arg-type]
werkzeug (https://github.com/pallets/werkzeug.git)
+ src/werkzeug/http.py:456: error: Unsupported operand types for + ("str" and "None")
+ src/werkzeug/http.py:456: note: Right operand is of type "Optional[str]"
+ src/werkzeug/http.py:458: error: Incompatible types in assignment (expression has type "Optional[str]", target has type "str")
|
|
I looked through the new mypy primer errors. I was too lazy to write notes about every repo I checked, but none of the errors look too bad to me. |
|
I am really unsure about this. On the one hand I am unhappy that we can't use a better return value, ideally optional, on the other hand I don't think the following (reduced) code from sphinx should be a type error: matched = py_ext_sig_re.match(self.name)
explicit_modname, path, base, args, retann = matched.groups()
parents = path.rstrip('.').split('.') if path else []From the first primer hit above. |
|
Isn't the How about a return type |
|
I am not a fan of either the status quo or the change. This means I am fine with this change, but I would also be fine with leaving it as is. |
|
Thank you for the PR. This has been superseded by #5557, which incorporated the ideas from this PR. |
Simple example regex to produce
NoneinMatch.groups()output can befoo(bar)?. The capturing group is optional sogroups()can have aNone.