Skip to content

re: group methods return AnyStr or None #10680

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

Closed
wants to merge 1 commit into from

Conversation

ehandal
Copy link
Contributor

@ehandal ehandal commented Sep 7, 2023

The group, groups, groupdict, and __getitem__ methods default to None if a group doesn't participate in a match.

The group, groups, groupdict, and __getitem__ methods default to None if a group doesn't participate in a match.
@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

Diff from mypy_primer, showing the effect of this PR on open source code:

python-chess (https://github.com/niklasf/python-chess)
+ chess/__init__.py:3020: error: Argument 1 to "index" of "list" has incompatible type "str | None"; expected "str"  [arg-type]
+ chess/__init__.py:3030: error: Argument 1 to "index" of "list" has incompatible type "str | None"; expected "str"  [arg-type]
+ chess/__init__.py:3033: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ chess/__init__.py:3038: error: Item "None" of "str | None" has no attribute "lower"  [union-attr]
+ chess/pgn.py:127: error: Unsupported left operand type for + ("None")  [operator]
+ chess/pgn.py:127: note: Left operand is of type "str | None"
+ chess/pgn.py:127: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ chess/pgn.py:127: note: Possible overload variants:
+ chess/pgn.py:127: note:     def __add__(self, str, /) -> str
+ chess/pgn.py:127: note: Both left and right operands are unions
+ chess/pgn.py:129: error: Incompatible return value type (got "str | None", expected "str")  [return-value]
+ chess/pgn.py:456: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ chess/pgn.py:464: error: Argument 1 to "float" has incompatible type "str | None"; expected "SupportsFloat | SupportsIndex | str | Buffer"  [arg-type]
+ chess/pgn.py:476: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ chess/pgn.py:508: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ chess/pgn.py:553: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ chess/pgn.py:553: error: Argument 1 to "float" has incompatible type "str | None"; expected "SupportsFloat | SupportsIndex | str | Buffer"  [arg-type]
+ chess/pgn.py:587: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ chess/pgn.py:587: error: Argument 1 to "float" has incompatible type "str | None"; expected "SupportsFloat | SupportsIndex | str | Buffer"  [arg-type]
+ chess/pgn.py:1599: error: Invalid index type "str | None" for "Headers"; expected type "str"  [index]
+ chess/pgn.py:1599: error: Incompatible types in assignment (expression has type "str | None", target has type "str")  [assignment]

vision (https://github.com/pytorch/vision)
+ torchvision/datasets/utils.py:493: error: Argument 1 to "int" has incompatible type "bytes | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]

mitmproxy (https://github.com/mitmproxy/mitmproxy)
+ mitmproxy/utils/strutils.py:111: error: Invalid index type "str | None" for "dict[str, str]"; expected type "str"  [index]
+ mitmproxy/net/server_spec.py:63: error: Item "None" of "str | None" has no attribute "startswith"  [union-attr]
+ mitmproxy/net/server_spec.py:63: error: Item "None" of "str | None" has no attribute "endswith"  [union-attr]
+ mitmproxy/net/server_spec.py:64: error: Value of type "str | None" is not indexable  [index]
+ mitmproxy/net/server_spec.py:65: error: Value of type variable "AnyStr" of "is_valid_host" cannot be "str | None"  [type-var]
+ mitmproxy/net/server_spec.py:69: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ mitmproxy/net/http/url.py:169: error: Item "None" of "str | None" has no attribute "encode"  [union-attr]
+ mitmproxy/net/http/url.py:176: error: Item "None" of "str | None" has no attribute "startswith"  [union-attr]
+ mitmproxy/net/http/url.py:176: error: Item "None" of "str | None" has no attribute "endswith"  [union-attr]
+ mitmproxy/net/http/url.py:177: error: Value of type "str | None" is not indexable  [index]
+ mitmproxy/net/http/url.py:178: error: Value of type variable "AnyStr" of "is_valid_host" cannot be "str | None"  [type-var]
+ mitmproxy/net/http/url.py:182: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ mitmproxy/net/http/url.py:185: error: Incompatible return value type (got "tuple[str | None, int]", expected "tuple[str, int | None]")  [return-value]
+ mitmproxy/net/http/url.py:187: error: Incompatible return value type (got "tuple[str | None, None]", expected "tuple[str, int | None]")  [return-value]
+ mitmproxy/net/http/multipart.py:74: error: Incompatible return value type (got "list[tuple[bytes | None, bytes]]", expected "list[tuple[bytes, bytes]]")  [return-value]
+ mitmproxy/http.py:422: error: Item "None" of "bytes | None" has no attribute "decode"  [union-attr]
+ mitmproxy/http.py:430: error: Item "None" of "bytes | None" has no attribute "decode"  [union-attr]

pip (https://github.com/pypa/pip)
+ src/pip/_internal/utils/encoding.py:32: error: Item "None" of "bytes | None" has no attribute "decode"  [union-attr]
+ src/pip/_internal/utils/compatibility_tags.py:30: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ src/pip/_internal/models/wheel.py:30: error: Item "None" of "str | None" has no attribute "replace"  [union-attr]
+ src/pip/_internal/models/wheel.py:33: error: Item "None" of "str | None" has no attribute "replace"  [union-attr]
+ src/pip/_internal/models/wheel.py:35: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ src/pip/_internal/models/wheel.py:36: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ src/pip/_internal/models/wheel.py:37: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ src/pip/_internal/vcs/subversion.py:154: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ src/pip/_internal/vcs/subversion.py:171: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ src/pip/_internal/vcs/git.py:104: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ src/pip/_internal/models/link.py:80: error: Argument "name" to "LinkHash" has incompatible type "str | None"; expected "str"  [arg-type]
+ src/pip/_internal/models/link.py:80: error: Argument "value" to "LinkHash" has incompatible type "str | None"; expected "str"  [arg-type]
+ src/pip/_internal/models/link.py:444: error: Argument 1 to "match" of "Pattern" has incompatible type "str | None"; expected "str"  [arg-type]
+ src/pip/_internal/index/package_finder.py:545: error: Incompatible types in assignment (expression has type "tuple[int, str | None]", variable has type "tuple[] | tuple[int, str]")  [assignment]
+ src/pip/_internal/index/package_finder.py:545: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ src/pip/_internal/req/constructors.py:51: error: Incompatible return value type (got "tuple[str | None, str | None]", expected "tuple[str, str | None]")  [return-value]

steam.py (https://github.com/Gobot1234/steam.py)
+ steam/id.py:456: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ steam/id.py:458: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ steam/id.py:476: error: Argument 1 to "ID32" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ steam/id.py:477: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ steam/id.py:478: error: Item "None" of "str | None" has no attribute "replace"  [union-attr]
+ steam/id.py:508: error: Item "None" of "str | None" has no attribute "replace"  [union-attr]
+ steam/id.py:563: error: Argument 1 has incompatible type "str | None"; expected "str | bytes"  [arg-type]
+ steam/utils.py:151: error: Argument 1 to "ID" has incompatible type "str | None"; expected "SupportsInt | SupportsIndex | str | bytes"  [arg-type]
+ steam/utils.py:644: error: Argument 1 to "BBCodeTag" has incompatible type "str | None"; expected "str"  [arg-type]
+ steam/utils.py:646: error: Argument 1 to "findall" of "Pattern" has incompatible type "str | None"; expected "str"  [arg-type]
+ steam/utils.py:647: error: Argument 4 to "BBCodeTag" has incompatible type "str | None"; expected "str"  [arg-type]
+ steam/utils.py:654: error: Argument 1 to "BBCodeTag" has incompatible type "str | None"; expected "str"  [arg-type]
+ steam/utils.py:656: error: Argument 1 to "findall" of "Pattern" has incompatible type "str | None"; expected "str"  [arg-type]
+ steam/utils.py:657: error: Argument 4 to "BBCodeTag" has incompatible type "str | None"; expected "str"  [arg-type]
+ steam/models.py:89: error: Item "None" of "str | None" has no attribute "replace"  [union-attr]
+ steam/models.py:90: error: Item "None" of "str | None" has no attribute "replace"  [union-attr]
+ steam/models.py:92: error: Incompatible types in assignment (expression has type "str | None", variable has type "float | str")  [assignment]
+ steam/models.py:93: error: Incompatible types in assignment (expression has type "str | None", variable has type "float | str")  [assignment]
+ steam/http.py:330: error: Argument 1 has incompatible type "str | None"; expected "str | bytes"  [arg-type]
+ steam/app.py:1688: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ steam/ext/csgo/client.py:95: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ steam/ext/csgo/client.py:96: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ steam/ext/csgo/client.py:97: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ steam/ext/csgo/client.py:98: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ steam/ext/tf2/backpack.py:338: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]

cloud-init (https://github.com/canonical/cloud-init)
+ cloudinit/sources/__init__.py:1198: error: Item "None" of "str | None" has no attribute "strip"  [union-attr]
+ cloudinit/sources/__init__.py:1209: error: Incompatible return value type (got "str | None", expected "str")  [return-value]
+ cloudinit/config/schema.py:605: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]

pandas (https://github.com/pandas-dev/pandas)
+ pandas/util/version/__init__.py:347: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ pandas/util/version/__init__.py:348: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ pandas/util/version/__init__.py:349: error: Argument 1 to "_parse_letter_version" has incompatible type "str | None"; expected "str"  [arg-type]
+ pandas/util/version/__init__.py:349: error: Argument 2 to "_parse_letter_version" has incompatible type "str | None"; expected "str | bytes | SupportsInt"  [arg-type]
+ pandas/util/version/__init__.py:351: error: Argument 1 to "_parse_letter_version" has incompatible type "str | None"; expected "str"  [arg-type]
+ pandas/util/version/__init__.py:351: error: Argument 2 to "_parse_letter_version" has incompatible type "str | None"; expected "str | bytes | SupportsInt"  [arg-type]
+ pandas/util/version/__init__.py:353: error: Argument 1 to "_parse_letter_version" has incompatible type "str | None"; expected "str"  [arg-type]
+ pandas/util/version/__init__.py:353: error: Argument 2 to "_parse_letter_version" has incompatible type "str | None"; expected "str | bytes | SupportsInt"  [arg-type]
+ pandas/util/version/__init__.py:354: error: Argument 1 to "_parse_local_version" has incompatible type "str | None"; expected "str"  [arg-type]
+ pandas/io/formats/css.py:358: error: Incompatible types in assignment (expression has type "int", variable has type "str | None")  [assignment]
+ pandas/io/formats/css.py:361: error: Incompatible types in assignment (expression has type "float", variable has type "str | None")  [assignment]
+ pandas/io/formats/css.py:361: error: Argument 1 to "float" has incompatible type "str | None"; expected "SupportsFloat | SupportsIndex | str | Buffer"  [arg-type]
+ pandas/io/formats/css.py:380: error: No overload variant of "round" matches argument types "str | None", "int"  [call-overload]
+ pandas/io/formats/css.py:380: note: Possible overload variants:
+ pandas/io/formats/css.py:380: note:     def [_T] round(number: _SupportsRound1[_T], ndigits: None = ...) -> _T
+ pandas/io/formats/css.py:380: note:     def [_T] round(number: _SupportsRound2[_T], ndigits: SupportsIndex) -> _T
+ pandas/io/formats/css.py:381: error: Non-overlapping equality check (left operand type: "int", right operand type: "str | None")  [comparison-overlap]
+ pandas/io/formats/css.py:381: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ pandas/io/formats/css.py:382: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ pandas/core/dtypes/dtypes.py:858: error: Argument "unit" to "DatetimeTZDtype" has incompatible type "str | None"; expected "str | DatetimeTZDtype"  [arg-type]
+ pandas/core/dtypes/dtypes.py:1036: error: Incompatible types in assignment (expression has type "str | None", variable has type "str")  [assignment]
+ pandas/core/dtypes/dtypes.py:1912: error: Incompatible return value type (got "tuple[str | None, bool]", expected "tuple[str, bool]")  [return-value]
+ pandas/core/interchange/from_dataframe.py:341: error: Unsupported left operand type for + ("None")  [operator]
+ pandas/core/interchange/from_dataframe.py:341: note: Left operand is of type "str | None"

manticore (https://github.com/trailofbits/manticore)
+ manticore/core/smtlib/solver.py:454: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, bytes, bytearray]"  [arg-type]

openlibrary (https://github.com/internetarchive/openlibrary)
+ openlibrary/catalog/marc/marc_base.py: note: In member "read_isbn" of class "MarcBase":
+ openlibrary/catalog/marc/marc_base.py:70: error: Incompatible return value type (got "list[str | None]", expected "list[str]")  [return-value]
+ openlibrary/utils/lcc.py: note: In function "short_lcc_to_sortable_lcc":
+ openlibrary/utils/lcc.py:123: error: Item "None" of "str | None" has no attribute "upper"  [union-attr]
+ openlibrary/utils/lcc.py:124: error: Incompatible types in assignment (expression has type "float", target has type "str | None")  [assignment]
+ openlibrary/utils/lcc.py: note: In function "sortable_lcc_to_short_lcc":
+ openlibrary/utils/lcc.py:145: error: Item "None" of "str | None" has no attribute "strip"  [union-attr]
+ openlibrary/utils/lcc.py:146: error: Item "None" of "str | None" has no attribute "strip"  [union-attr]
+ openlibrary/solr/read_dump.py:97: error: Unsupported left operand type for + ("None")  [operator]
+ openlibrary/solr/read_dump.py:97: note: Left operand is of type "str | None"
+ openlibrary/solr/db_load_authors.py:20: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ openlibrary/catalog/utils/__init__.py: note: In function "flip_name":
+ openlibrary/catalog/utils/__init__.py:88: error: Unsupported left operand type for + ("None")  [operator]
+ openlibrary/catalog/utils/__init__.py:88: note: Left operand is of type "str | None"
+ openlibrary/catalog/utils/__init__.py:88: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ openlibrary/catalog/utils/__init__.py:88: note: Possible overload variants:
+ openlibrary/catalog/utils/__init__.py:88: note:     def __add__(self, str, /) -> str
+ openlibrary/catalog/utils/__init__.py:88: note: Both left and right operands are unions
+ openlibrary/catalog/utils/__init__.py: note: In function "mk_norm":
+ openlibrary/catalog/utils/__init__.py:285: error: Incompatible types in assignment (expression has type "str | None", variable has type "str")  [assignment]
+ openlibrary/catalog/marc/parse.py: note: In function "read_lccn":
+ openlibrary/catalog/marc/parse.py:114: error: Item "None" of "str | None" has no attribute "strip"  [union-attr]
+ openlibrary/catalog/marc/parse.py: note: In function "read_oclc":
+ openlibrary/catalog/marc/parse.py:138: error: Incompatible types in assignment (expression has type "str | None", variable has type "str")  [assignment]
+ openlibrary/catalog/marc/parse.py:147: error: Item "None" of "str | None" has no attribute "isdigit"  [union-attr]
+ openlibrary/catalog/marc/parse.py:150: error: Incompatible types in assignment (expression has type "str | None", variable has type "str")  [assignment]
+ openlibrary/catalog/marc/parse.py: note: In function "read_title":
+ openlibrary/catalog/marc/parse.py:266: error: Incompatible types in assignment (expression has type "str | None", variable has type "str")  [assignment]
+ openlibrary/plugins/openlibrary/stats.py: note: In function "find_topmost_useful_file":
+ openlibrary/plugins/openlibrary/stats.py:302: error: Incompatible types in assignment (expression has type "str | None", variable has type "str")  [assignment]
+ openlibrary/solr/update_edition.py: note: In member "languages" of class "EditionSolrBuilder":
+ openlibrary/solr/update_edition.py:75: error: Argument 1 to "append" of "list" has incompatible type "str | None"; expected "str"  [arg-type]
+ openlibrary/solr/update_edition.py: note: In member "publish_year" of class "EditionSolrBuilder":
+ openlibrary/solr/update_edition.py:120: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ openlibrary/solr/update_work.py: note: In function "extract_edition_olid":
+ openlibrary/solr/update_work.py:97: error: Incompatible return value type (got "str | None", expected "str")  [return-value]
+ openlibrary/solr/update_work.py: note: In function "build_data2":
+ openlibrary/solr/update_work.py:887: error: Argument 1 to "join" of "str" has incompatible type "tuple[str | None, Any]"; expected "Iterable[str]"  [arg-type]
+ openlibrary/solr/update_work.py: note: At top level:

python-htmlgen (https://github.com/srittau/python-htmlgen)
+ test_htmlgen/util.py:13: error: Argument 1 to "findall" of "Pattern" has incompatible type "str | None"; expected "str"  [arg-type]
+ test_htmlgen/element.py:115: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ test_htmlgen/element.py:124: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ test_htmlgen/element.py:152: error: Item "None" of "str | None" has no attribute "split"  [union-attr]

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/cookiejar.py:347:57: error: Argument 1 to "match" of "Pattern" has incompatible type "str | None"; expected "str"  [arg-type]
+ aiohttp/cookiejar.py:350:49: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ aiohttp/cookiejar.py:354:60: error: Argument 1 to "match" of "Pattern" has incompatible type "str | None"; expected "str"  [arg-type]
+ aiohttp/cookiejar.py:361:55: error: Argument 1 to "match" of "Pattern" has incompatible type "str | None"; expected "str"  [arg-type]
+ aiohttp/cookiejar.py:369:53: error: Argument 1 to "match" of "Pattern" has incompatible type "str | None"; expected "str"  [arg-type]
+ aiohttp/http_websocket.py:202:36: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ aiohttp/http_websocket.py:216:36: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ aiohttp/http_websocket.py:229:36: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ aiohttp/http_websocket.py:229:36: note: Possible overload variants:
+ aiohttp/http_websocket.py:229:36: note:     def __add__(self, str, /) -> str
+ aiohttp/http_websocket.py:229:36: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-operator for more info
+ aiohttp/http_websocket.py:229:36: note: Right operand is of type "str | None"
+ aiohttp/http_parser.py:611:37: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ aiohttp/client_reqrep.py:830:22: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ aiohttp/client_reqrep.py:830:22: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-union-attr for more info
+ aiohttp/client_reqrep.py:841:26: error: Argument 1 to "add" of "MultiDict" has incompatible type "str | None"; expected "str | istr"  [arg-type]
+ aiohttp/client_reqrep.py:841:31: error: Argument 2 to "add" of "MultiDict" has incompatible type "str | None"; expected "str | URL"  [arg-type]
+ aiohttp/client_reqrep.py:843:19: error: Incompatible types in assignment (expression has type "str | URL | None", variable has type "str | None")  [assignment]
+ aiohttp/client_reqrep.py:845:47: error: Argument 1 to "URL" has incompatible type "str | None"; expected "str | URL"  [arg-type]
+ aiohttp/web_response.py:276:19: error: Argument "value" to "ETag" has incompatible type "str | None"; expected "str"  [arg-type]
+ aiohttp/web_request.py:350:28: error: Value of type "str | None" is not indexable  [index]
+ aiohttp/web_request.py:350:28: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-index for more info
+ aiohttp/web_request.py:352:72: error: Value of type "str | None" is not indexable  [index]
+ aiohttp/web_request.py:354:29: error: Unsupported left operand type for + ("None")  [operator]
+ aiohttp/web_request.py:354:29: note: Left operand is of type "str | None"
+ aiohttp/web_request.py:355:30: error: Item "None" of "str | None" has no attribute "lower"  [union-attr]
+ aiohttp/web_request.py:355:46: error: Incompatible types in assignment (expression has type "str | None", target has type "str")  [assignment]
+ aiohttp/web_request.py:526:27: error: Argument "value" to "ETag" has incompatible type "str | None"; expected "str"  [arg-type]
+ aiohttp/web_urldispatcher.py:430:30: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ aiohttp/web_urldispatcher.py:430:30: note: Possible overload variants:
+ aiohttp/web_urldispatcher.py:430:30: note:     def __add__(self, str, /) -> str
+ aiohttp/web_urldispatcher.py:430:30: note: Right operand is of type "str | None"
+ aiohttp/web_urldispatcher.py:436:30: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ aiohttp/web_urldispatcher.py:436:30: note: Possible overload variants:
+ aiohttp/web_urldispatcher.py:436:30: note:     def __add__(self, str, /) -> str
+ aiohttp/web_urldispatcher.py:436:30: note: Right operand is of type "str | None"
+ aiohttp/web_urldispatcher.py:472:36: error: Argument 1 to "_unquote_path" has incompatible type "str | None"; expected "str"  [arg-type]

pylox (https://github.com/sco1/pylox)
+ pylox/preprocessor.py:70: error: Value of type "str | None" is not indexable  [index]
+ pylox/preprocessor.py:73: error: Item "None" of "str | None" has no attribute "strip"  [union-attr]
+ pylox/preprocessor.py:77: error: Item "None" of "str | None" has no attribute "strip"  [union-attr]
+ pylox/preprocessor.py:80: error: Value of type "str | None" is not indexable  [index]

pydantic (https://github.com/samuelcolvin/pydantic)
+ pydantic/alias_generators.py:17: error: Argument 2 to "sub" has incompatible type "Callable[[Match[str]], str | None]"; expected "str | Callable[[Match[str]], str]"  [arg-type]
+ pydantic/alias_generators.py:17: error: Incompatible return value type (got "str | None", expected "str")  [return-value]
+ pydantic/alias_generators.py:30: error: Item "None" of "str | None" has no attribute "lower"  [union-attr]
+ pydantic/errors.py:111: error: Incompatible types in assignment (expression has type "str | Any | None", variable has type "str")  [assignment]
+ pydantic/errors.py:111: note: Error code "assignment" not covered by "type: ignore" comment
+ pydantic/v1/datetime_parse.py:129: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ pydantic/v1/datetime_parse.py:241: error: Item "None" of "str | None" has no attribute "ljust"  [union-attr]
+ pydantic/v1/datetime_parse.py:243: error: Item "None" of "str | None" has no attribute "startswith"  [union-attr]
+ pydantic/v1/datetime_parse.py:244: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ pydantic/v1/datetime_parse.py:244: note: Possible overload variants:
+ pydantic/v1/datetime_parse.py:244: note:     def __add__(self, str, /) -> str
+ pydantic/v1/datetime_parse.py:244: note: Right operand is of type "str | None"
+ pydantic/v1/color.py:242: error: Unsupported operand types for * ("None" and "int")  [operator]
+ pydantic/v1/color.py:242: note: Left operand is of type "str | None"
+ pydantic/v1/color.py:242: error: Argument 1 to "int" has incompatible type "str | int"; expected "str | bytes | bytearray"  [arg-type]
+ pydantic/v1/color.py:252: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | bytes | bytearray"  [arg-type]
+ pydantic/v1/color.py:270: error: Argument 1 to "parse_hsl" has incompatible type "str | None"; expected "str"  [arg-type]
+ pydantic/v1/color.py:270: error: Argument 2 to "parse_hsl" has incompatible type "str | None"; expected "str"  [arg-type]
+ pydantic/v1/color.py:270: error: Argument 3 to "parse_hsl" has incompatible type "str | None"; expected "str"  [arg-type]
+ pydantic/v1/color.py:270: error: Argument 4 to "parse_hsl" has incompatible type "str | None"; expected "str"  [arg-type]
+ pydantic/v1/color.py:275: error: Argument 1 to "parse_hsl" has incompatible type "str | None"; expected "str"  [arg-type]
+ pydantic/v1/color.py:275: error: Argument 2 to "parse_hsl" has incompatible type "str | None"; expected "str"  [arg-type]
+ pydantic/v1/color.py:275: error: Argument 3 to "parse_hsl" has incompatible type "str | None"; expected "str"  [arg-type]
+ pydantic/v1/color.py:275: error: Argument 4 to "parse_hsl" has incompatible type "str | None"; expected "str"  [arg-type]
+ pydantic/v1/types.py:1116: error: Argument 1 to "float" has incompatible type "str | None"; expected "SupportsFloat | SupportsIndex | str | Buffer"  [arg-type]
+ pydantic/v1/networks.py:442: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ pydantic/v1/networks.py:720: error: Incompatible types in assignment (expression has type "str | None", variable has type "str")  [assignment]
+ pydantic/types.py:950: error: Argument 1 to "float" has incompatible type "str | None"; expected "SupportsFloat | SupportsIndex | str | Buffer"  [arg-type]
+ pydantic/networks.py:416: error: Incompatible types in assignment (expression has type "str | None", variable has type "str")  [assignment]
+ pydantic/color.py:310: error: Unsupported operand types for * ("None" and "int")  [operator]
+ pydantic/color.py:310: note: Left operand is of type "str | None"
+ pydantic/color.py:310: error: Argument 1 to "int" has incompatible type "str | int"; expected "str | bytes | bytearray"  [arg-type]
+ pydantic/color.py:320: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | bytes | bytearray"  [arg-type]

prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/software/conda.py:68: error: Incompatible types in assignment (expression has type "str | None", variable has type "str")  [assignment]

pycryptodome (https://github.com/Legrandin/pycryptodome)
+ lib/Crypto/SelfTest/Signature/test_dss.py:169: error: Item "None" of "str | None" has no attribute "replace"  [union-attr]
+ lib/Crypto/SelfTest/Signature/test_dss.py:207: error: Item "None" of "str | None" has no attribute "replace"  [union-attr]
+ lib/Crypto/SelfTest/Signature/test_dss.py:329: error: Item "None" of "str | None" has no attribute "replace"  [union-attr]
+ lib/Crypto/SelfTest/Signature/test_dss.py:342: error: Argument "curve" to "construct" has incompatible type "str | None"; expected "str | int"  [arg-type]
+ lib/Crypto/SelfTest/Signature/test_dss.py:368: error: Item "None" of "str | None" has no attribute "replace"  [union-attr]
+ lib/Crypto/SelfTest/Signature/test_dss.py:373: error: Argument "curve" to "construct" has incompatible type "str | None"; expected "str | int"  [arg-type]
+ lib/Crypto/SelfTest/Protocol/test_ecdh.py:39: error: Argument "curve" to "construct" has incompatible type "str | None"; expected "str | int"  [arg-type]
+ lib/Crypto/SelfTest/Protocol/test_ecdh.py:43: error: Argument "curve" to "construct" has incompatible type "str | None"; expected "str | int"  [arg-type]

git-revise (https://github.com/mystor/git-revise)
+ gitrevise/odb.py:112: error: Item "None" of "Optional[bytes]" has no attribute "strip"  [union-attr]
+ gitrevise/odb.py:119: error: Item "None" of "Optional[bytes]" has no attribute "strip"  [union-attr]
+ gitrevise/odb.py:126: error: Item "None" of "Optional[bytes]" has no attribute "strip"  [union-attr]
+ gitrevise/odb.py:133: error: Item "None" of "Optional[bytes]" has no attribute "strip"  [union-attr]
+ gitrevise/odb.py:140: error: Item "None" of "Optional[bytes]" has no attribute "strip"  [union-attr]
+ gitrevise/todo.py:58: error: Argument 1 to "parse" of "StepKind" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ gitrevise/todo.py:59: error: Argument 1 to "get_commit" of "Repository" has incompatible type "Optional[str]"; expected "Union[Oid, str]"  [arg-type]

ignite (https://github.com/pytorch/ignite)
+ ignite/distributed/comp_models/native.py:545: error: Unsupported left operand type for + ("None")  [operator]
+ ignite/distributed/comp_models/native.py:545: note: Left operand is of type "str | None"
+ ignite/distributed/comp_models/native.py:548: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ ignite/distributed/comp_models/native.py:548: note: Possible overload variants:
+ ignite/distributed/comp_models/native.py:548: note:     def __add__(self, str, /) -> str
+ ignite/distributed/comp_models/native.py:548: note: Both left and right operands are unions

sympy (https://github.com/sympy/sympy)
+ sympy/core/expr.py:388: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]

alectryon (https://github.com/cpitclaudel/alectryon)
+ alectryon/literate.py:682: error: Argument 1 to "len" has incompatible type "str | None"; expected "Sized"  [arg-type]

com2ann (https://github.com/ilevkivskyi/com2ann)
+ src/com2ann.py:424: error: Item "None" of "Optional[str]" has no attribute "lstrip"  [union-attr]
+ src/com2ann.py:430: error: Argument 1 to "split_sub_comment" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ src/com2ann.py:433: error: Argument 2 to "search" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ src/com2ann.py:435: error: Value of type "Optional[str]" is not indexable  [index]
+ src/com2ann.py:472: error: Item "None" of "Optional[str]" has no attribute "lstrip"  [union-attr]

anyio (https://github.com/agronholm/anyio)
+ src/anyio/streams/tls.py:211: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]

pandera (https://github.com/pandera-dev/pandera)
+ tests/mypy/test_static_type_checking.py:41: error: Dict entry 0 has incompatible type "str": "str | None"; expected "str": "str"  [dict-item]
+ tests/mypy/test_static_type_checking.py:42: error: Dict entry 1 has incompatible type "str": "str | None"; expected "str": "str"  [dict-item]

rich (https://github.com/Textualize/rich)
+ rich/_emoji_replace.py:26: error: Item "None" of "str | None" has no attribute "lower"  [union-attr]
+ rich/_emoji_replace.py:27: error: Argument 1 has incompatible type "str | None"; expected "str"  [arg-type]
+ rich/_emoji_replace.py:30: error: Incompatible return value type (got "str | None", expected "str")  [return-value]
+ rich/text.py:1265: error: Argument 1 to "len" has incompatible type "str | None"; expected "Sized"  [arg-type]
+ rich/text.py:1312: error: Argument 1 to "len" has incompatible type "str | None"; expected "Sized"  [arg-type]
+ rich/markup.py:96: error: Value of type "str | None" is not indexable  [index]
+ rich/markup.py:99: error: Item "None" of "str | None" has no attribute "partition"  [union-attr]
+ rich/markup.py:181: error: Incompatible types in assignment (expression has type "str | None", variable has type "str")  [assignment]
+ rich/color.py:471: error: Item "None" of "str | None" has no attribute "split"  [union-attr]

starlette (https://github.com/encode/starlette)
+ starlette/routing.py:254: error: Argument 1 to "convert" of "Convertor" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ starlette/routing.py:336: error: Argument 1 to "convert" of "Convertor" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ starlette/routing.py:409: error: Argument 1 to "convert" of "Convertor" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ starlette/routing.py:410: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ starlette/routing.py:410: note: Possible overload variants:
+ starlette/routing.py:410: note:     def __add__(self, str, /) -> str
+ starlette/routing.py:410: note: Right operand is of type "Optional[str]"
+ starlette/routing.py:496: error: Argument 1 to "convert" of "Convertor" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ tests/middleware/test_session.py:47: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]

dragonchain (https://github.com/dragonchain/dragonchain)
+ dragonchain/lib/authorization.py:319:58: error: Argument 1 to "get_supported_hmac_hash" has incompatible type "Union[str, None, Any]"; expected "str"  [arg-type]
+ dragonchain/lib/authorization.py:342:56: error: Argument 1 to "get_api_key" has incompatible type "Union[str, None, Any]"; expected "str"  [arg-type]
+ dragonchain/lib/authorization.py:347:57: error: Argument 1 to "should_rate_limit" has incompatible type "Union[str, None, Any]"; expected "str"  [arg-type]

SinbadCogs (https://github.com/mikeshardmind/SinbadCogs)
+ modnotes/converters.py:40: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ relays/helpers.py:106: error: Argument 1 to "int" has incompatible type "Union[Any, str, None]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]

cki-lib (https://gitlab.com/cki-project/cki-lib)
+ cki_lib/gitlab_yaml_shellcheck.py:126: error: Item "None" of "str | None" has no attribute "split"  [union-attr]

operator (https://github.com/canonical/operator)
+ ops/jujuversion.py:45: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ ops/jujuversion.py:46: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ ops/_private/timeconv.py:45: error: Argument 1 to "match" of "Pattern" has incompatible type "str | None"; expected "str"  [arg-type]
+ ops/_private/timeconv.py:49: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ ops/_private/timeconv.py:54: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ ops/model.py:3010: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ ops/model.py:3011: error: Argument 1 to "storage_get" of "_ModelBackend" has incompatible type "str | None"; expected "str"  [arg-type]

nox (https://github.com/wntrblm/nox)
+ nox/virtualenv.py:423: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  [assignment]

tornado (https://github.com/tornadoweb/tornado)
+ tornado/util.py:201: error: Value of type "Optional[str]" is not indexable  [index]
+ tornado/util.py:202: error: Value of type "Optional[str]" is not indexable  [index]
+ tornado/util.py:203: error: Incompatible return value type (got "Optional[str]", expected "str")  [return-value]
+ tornado/escape.py:344: error: Incompatible return value type (got "Optional[Any]", expected "str")  [return-value]
+ tornado/escape.py:347: error: Incompatible return value type (got "Optional[Any]", expected "str")  [return-value]
+ tornado/escape.py:351: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ tornado/escape.py:351: note: Possible overload variants:
+ tornado/escape.py:351: note:     def __add__(self, str, /) -> str
+ tornado/escape.py:351: note: Right operand is of type "Optional[Any]"
+ tornado/escape.py:354: error: Argument 1 has incompatible type "Optional[Any]"; expected "str"  [arg-type]
+ tornado/escape.py:360: error: Argument 1 to "len" has incompatible type "Optional[Any]"; expected "Sized"  [arg-type]
+ tornado/escape.py:367: error: Value of type "Optional[Any]" is not indexable  [index]
+ tornado/escape.py:374: error: Value of type "Optional[Any]" is not indexable  [index]
+ tornado/escape.py:380: error: Argument 1 to "len" has incompatible type "Optional[Any]"; expected "Sized"  [arg-type]
+ tornado/escape.py:381: error: Value of type "Optional[Any]" is not indexable  [index]
+ tornado/escape.py:384: error: Item "None" of "Optional[Any]" has no attribute "rfind"  [union-attr]
+ tornado/escape.py:387: error: Value of type "Optional[Any]" is not indexable  [index]
+ tornado/escape.py:388: error: Unsupported left operand type for + ("None")  [operator]
+ tornado/escape.py:388: note: Left operand is of type "Optional[Any]"
+ tornado/escape.py:390: error: Argument 1 to "len" has incompatible type "Optional[Any]"; expected "Sized"  [arg-type]
+ tornado/options.py:664: error: Argument 1 to "float" has incompatible type "Optional[str]"; expected "Union[SupportsFloat, SupportsIndex, str, Buffer]"  [arg-type]
+ tornado/httputil.py:925: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ tornado/httputil.py:1040: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ tornado/httputil.py:1044: error: Incompatible return value type (got "Tuple[Optional[str], Optional[int]]", expected "Tuple[str, Optional[int]]")  [return-value]
+ tornado/routing.py:586: error: Generator has incompatible item type "Tuple[str, Optional[bytes]]"; expected "Tuple[str, bytes]"  [misc]
+ tornado/routing.py:589: error: List comprehension has incompatible type List[Optional[bytes]]; expected List[bytes]  [misc]
+ tornado/web.py:1550: error: Argument 1 to "int" has incompatible type "Optional[bytes]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ tornado/web.py:3548: error: Argument 1 to "int" has incompatible type "Optional[bytes]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ tornado/test/web_test.py:142: error: Argument 4 to "_create_signature_v1" has incompatible type "Optional[bytes]"; expected "Union[str, bytes]"  [arg-type]
+ tornado/test/web_test.py:154: error: Unsupported operand types for + ("bytes" and "None")  [operator]
+ tornado/test/web_test.py:154: note: Right operand is of type "Optional[bytes]"
+ tornado/test/web_test.py:410: error: Argument 1 to "parsedate_to_datetime" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ tornado/test/web_test.py:3052: error: Argument 1 to "parsedate_to_datetime" has incompatible type "Optional[str]"; expected "str"  [arg-type]

pylint (https://github.com/pycqa/pylint)
+ pylint/pyreverse/utils.py:259: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ pylint/lint/message_state_handler.py:357: error: Argument 1 to "parse_pragma" has incompatible type "str | None"; expected "str"  [arg-type]
+ pylint/checkers/strings.py:1063: error: Incompatible return value type (got "str | None", expected "str")  [return-value]
+ pylint/checkers/spelling.py:198: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ pylint/checkers/spelling.py:198: note: Possible overload variants:
+ pylint/checkers/spelling.py:198: note:     def __add__(self, str, /) -> str
+ pylint/checkers/spelling.py:198: error: Unsupported left operand type for + ("None")  [operator]
+ pylint/checkers/spelling.py:198: note: Both left and right operands are unions
+ pylint/checkers/format.py:591: error: Argument 1 to "parse_pragma" has incompatible type "str | None"; expected "str"  [arg-type]

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/util/nodes.py: note: In function "split_explicit_title":
+ sphinx/util/nodes.py:353:16: error: Incompatible return value type (got "tuple[bool, Optional[str], Optional[str]]", expected "tuple[bool, str, str]")  [return-value]
+ sphinx/util/inventory.py: note: In member "load_v2" of class "InventoryFile":
+ sphinx/util/inventory.py:124:16: error: Unsupported right operand type for in ("Optional[str]")  [operator]
+ sphinx/util/inventory.py:135:16: error: Item "None" of "Optional[str]" has no attribute "endswith"  [union-attr]
+ sphinx/util/inventory.py:136:28: error: Value of type "Optional[str]" is not indexable  [index]
+ sphinx/util/inventory.py:136:28: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ sphinx/util/inventory.py:136:28: note: Possible overload variants:
+ sphinx/util/inventory.py:136:28: note:     def __add__(self, str, /) -> str
+ sphinx/util/inventory.py:136:28: note: Both left and right operands are unions
+ sphinx/util/inventory.py:138:39: error: Incompatible types in assignment (expression has type "tuple[str, str, Optional[str], Optional[str]]", variable has type "tuple[str, str, str, str]")  [assignment]
+ sphinx/util/inventory.py:139:32: error: Argument 1 to "setdefault" of "MutableMapping" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ sphinx/util/inventory.py:139:42: error: Invalid index type "Optional[str]" for "dict[str, tuple[str, str, str, str]]"; expected type "str"  [index]
+ sphinx/util/docutils.py: note: In member "write" of class "WarningStream":
+ sphinx/util/docutils.py:352:24: error: Argument 1 to "log" of "SphinxLoggerAdapter" has incompatible type "Optional[str]"; expected "Union[int, str]"  [arg-type]
+ sphinx/environment/adapters/indexentries.py: note: In member "create_index" of class "IndexEntries":
+ sphinx/environment/adapters/indexentries.py:109:33: error: Argument 1 to "setdefault" of "MutableMapping" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ sphinx/environment/adapters/indexentries.py:112:35: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  [assignment]
+ sphinx/writers/html5.py: note: In function "multiply_length":
+ sphinx/writers/html5.py:42:20: error: Argument 1 to "float" has incompatible type "Optional[str]"; expected "Union[SupportsFloat, SupportsIndex, str, Buffer]"  [arg-type]
+ sphinx/transforms/__init__.py: note: In member "apply" of class "ManpageLink":
+ sphinx/transforms/__init__.py:400:24: error: Incompatible types in assignment (expression has type "dict[str, Optional[str]]", variable has type "dict[str, str]")  [assignment]
+ sphinx/domains/std.py: note: In member "handle_signature" of class "Cmdoption":
+ sphinx/domains/std.py:161:16: error: Value of type "Optional[str]" is not indexable  [index]
+ sphinx/domains/std.py:163:27: error: Value of type "Optional[str]" is not indexable  [index]
+ sphinx/domains/std.py:164:24: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ sphinx/domains/std.py:164:24: note: Possible overload variants:
+ sphinx/domains/std.py:164:24: note:     def __add__(self, str, /) -> str
+ sphinx/domains/std.py:164:24: note: Right operand is of type "Optional[str]"
+ sphinx/domains/std.py:196:29: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  [assignment]
+ sphinx/domains/std.py: note: At top level:
+ sphinx/domains/std.py: note: In function "token_xrefs":
+ sphinx/domains/std.py:422:12: error: Unsupported right operand type for in ("Optional[str]")  [operator]
+ sphinx/domains/std.py:423:16: error: Value of type "Optional[str]" is not indexable  [index]
+ sphinx/domains/std.py:424:28: error: Item "None" of "Optional[str]" has no attribute "split"  [union-attr]
+ sphinx/domains/std.py:425:26: error: Value of type "Optional[str]" is not indexable  [index]
+ sphinx/domains/std.py:426:18: error: Value of type "Optional[str]" is not indexable  [index]
+ sphinx/domains/std.py:427:25: error: Value of type "Optional[str]" is not indexable  [index]
+ sphinx/domains/std.py:434:22: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ sphinx/domains/std.py:434:22: note: Possible overload variants:
+ sphinx/domains/std.py:434:22: note:     def __add__(self, str, /) -> str
+ sphinx/domains/std.py:434:22: note: Right operand is of type "Optional[str]"
+ sphinx/domains/std.py: note: At top level:
+ sphinx/domains/python.py: note: In member "handle_signature" of class "PyObject":
+ sphinx/domains/python.py:735:28: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ sphinx/domains/python.py:735:28: note: Possible overload variants:
+ sphinx/domains/python.py:735:28: note:     def __add__(self, str, /) -> str
+ sphinx/domains/python.py:735:28: note: Right operand is of type "Optional[str]"
+ sphinx/domains/python.py:749:28: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ sphinx/domains/python.py:749:28: note: Possible overload variants:
+ sphinx/domains/python.py:749:28: note:     def __add__(self, str, /) -> str
+ sphinx/domains/python.py:749:28: note: Right operand is of type "Optional[str]"
+ sphinx/domains/python.py:832:16: error: Incompatible return value type (got "tuple[Union[str, Any], Optional[str]]", expected "tuple[str, str]")  [return-value]
+ sphinx/transforms/i18n.py: note: In function "parse_noqa":
+ sphinx/transforms/i18n.py:89:16: error: Incompatible return value type (got "tuple[Optional[str], bool]", expected "tuple[str, bool]")  [return-value]
+ sphinx/ext/autodoc/__init__.py: note: In member "parse_name" of class "Documenter":
+ sphinx/ext/autodoc/__init__.py:402:73: error: Argument 3 to "resolve_name" of "Documenter" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ sphinx/ext/autodoc/__init__.py:402:79: error: Argument 4 to "resolve_name" of "Documenter" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ sphinx/ext/autodoc/__init__.py:409:23: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  [assignment]
+ sphinx/ext/autodoc/__init__.py: note: In member "format_signature" of class "Documenter":
+ sphinx/ext/autodoc/__init__.py:503:32: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  [assignment]
+ sphinx/builders/_epub_base.py: note: In member "fix_ids" of class "EpubBuilder":
+ sphinx/builders/_epub_base.py:283:61: error: Argument 1 to "fix_fragment" of "EpubBuilder" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ sphinx/builders/_epub_base.py:283:73: error: Argument 2 to "fix_fragment" of "EpubBuilder" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ sphinx/builders/_epub_base.py: note: In member "fix_genindex" of class "EpubBuilder":
+ sphinx/builders/_epub_base.py:384:55: error: Argument 1 to "fix_fragment" of "EpubBuilder" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ sphinx/builders/_epub_base.py:384:67: error: Argument 2 to "fix_fragment" of "EpubBuilder" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ sphinx/builders/_epub_base.py:390:67: error: Argument 1 to "fix_fragment" of "EpubBuilder" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ sphinx/builders/_epub_base.py:390:79: error: Argument 2 to "fix_fragment" of "EpubBuilder" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ sphinx/writers/latex.py: note: In function "rstdim_to_latexdim":
+ sphinx/writers/latex.py:268:15: error: Argument 1 to "float" has incompatible type "Optional[str]"; expected "Union[SupportsFloat, SupportsIndex, str, Buffer]"  [arg-type]
+ sphinx/writers/latex.py:274:46: error: Argument 1 to "float" has incompatible type "Optional[str]"; expected "Union[SupportsFloat, SupportsIndex, str, Buffer]"  [arg-type]
+ sphinx/writers/latex.py:276:30: error: Argument 1 to "float" has incompatible type "Optional[str]"; expected "Union[SupportsFloat, SupportsIndex, str, Buffer]"  [arg-type]
+ sphinx/domains/rst.py: note: In function "parse_directive":
+ sphinx/domains/rst.py:105:8: error: Item "None" of "Optional[str]" has no attribute "strip"  [union-attr]
+ sphinx/domains/rst.py:106:17: error: Item "None" of "Optional[str]" has no attribute "strip"  [union-attr]
+ sphinx/domains/rst.py:108:17: error: Item "None" of "Optional[str]" has no attribute "strip"  [union-attr]
+ sphinx/ext/imgmath.py: note: In function "read_svg_depth":
+ sphinx/ext/imgmath.py:78:24: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ sphinx/ext/imgmath.py: note: In function "convert_dvi_to_png":
+ sphinx/ext/imgmath.py:196:29: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ sphinx/ext/imgmath.py: note: In function "convert_dvi_to_svg":
+ sphinx/ext/imgmath.py:217:37: error: Argument 1 to "float" has incompatible type "Optional[str]"; expected "Union[SupportsFloat, SupportsIndex, str, Buffer]"  [arg-type]
+ sphinx/ext/extlinks.py: note: In member "check_uri" of class "ExternalLinksChecker":
+ sphinx/ext/extlinks.py:79:17: error: Unsupported right operand type for in ("Optional[Any]")  [operator]
+ sphinx/ext/coverage.py: note: In member "build_c_coverage" of class "CoverageBuilder":
+ sphinx/ext/coverage.py:129:43: error: Argument 1 to "add" of "set" has incompatible type "tuple[str, Optional[str]]"; expected "tuple[str, str]"  [arg-type]
+ sphinx/ext/coverage.py:132:32: error: Unsupported operand types for in ("Optional[str]" and "str")  [operator]
+ sphinx/ext/coverage.py:134:50: error: Argument 1 to "match" of "Pattern" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ sphinx/ext/coverage.py:137:47: error: Argument 1 to "add" of "set" has incompatible type "tuple[str, Optional[str]]"; expected "tuple[str, str]"  [arg-type]
+ sphinx/ext/napoleon/docstring.py: note: In member "_consume_field" of class "GoogleDocstring":
+ sphinx/ext/napoleon/docstring.py:295:25: error: Item "None" of "Optional[str]" has no attribute "strip"  [union-attr]
+ sphinx/ext/napoleon/docstring.py:296:25: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  [assignment]
+ sphinx/ext/napoleon/docstring.py: note: In member "_parse_raises_section" of class "GoogleDocstring":
+ sphinx/ext/napoleon/docstring.py:768:25: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  [assignment]
+ sphinx/ext/napoleon/docstring.py: note: In function "_parse_numpydoc_see_also_section":
+ sphinx/ext/napoleon/docstring.py:1280:28: error: Incompatible return value type (got "tuple[Optional[str], None]", expected "tuple[str, Optional[str]]")  [return-value]
+ sphinx/ext/napoleon/docstring.py:1282:28: error: Incompatible return value type (got "tuple[Optional[str], str]", expected "tuple[str, Optional[str]]")  [return-value]
+ sphinx/ext/autosummary/__init__.py: note: In function "mangle_signature":
+ sphinx/ext/autosummary/__init__.py:494:24: error: Argument 2 to "insert" of "list" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ sphinx/ext/autosummary/__init__.py:495:13: error: Value of type "Optional[str]" is not indexable  [index]
+ sphinx/ext/autosummary/generate.py: note: In function "find_autosummary_in_lines":
+ sphinx/ext/autosummary/generate.py:634:44: error: Argument 2 to "join" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ sphinx/ext/autosummary/generate.py:639:28: error: Item "None" of "Optional[str]" has no attribute "strip"  [union-attr]
+ sphinx/ext/autosummary/generate.py:647:24: error: Item "None" of "Optional[str]" has no attribute "strip"  [union-attr]
+ sphinx/ext/autosummary/generate.py:664:27: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  [assignment]
+ sphinx/ext/autosummary/generate.py:672:30: error: Item "None" of "Optional[str]" has no attribute "strip"  [union-attr]
+ sphinx/directives/other.py: note: In member "parse_content" of class "TocTree":
+ sphinx/directives/other.py:124:27: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  [assignment]
+ sphinx/directives/other.py: note: At top level:
+ sphinx/writers/texinfo.py: note: In member "tex_image_length" of class "TexinfoTranslator":
+ sphinx/writers/texinfo.py:457:37: error: Argument 1 to "float" has incompatible type "Optional[str]"; expected "Union[SupportsFloat, SupportsIndex, str, Buffer]"  [arg-type]
+ sphinx/ext/inheritance_diagram.py: note: In function "try_import":
+ sphinx/ext/inheritance_diagram.py:99:36: error: Argument 2 to "getattr" has incompatible type "Optional[str]"; expected "str"  [arg-type]

scikit-learn (https://github.com/scikit-learn/scikit-learn)
+ sklearn/externals/_packaging/version.py:301: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ sklearn/externals/_packaging/version.py:302: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ sklearn/externals/_packaging/version.py:303: error: Argument 1 to "_parse_letter_version" has incompatible type "str | None"; expected "str"  [arg-type]
+ sklearn/externals/_packaging/version.py:303: error: Argument 2 to "_parse_letter_version" has incompatible type "str | None"; expected "str | bytes | SupportsInt"  [arg-type]
+ sklearn/externals/_packaging/version.py:305: error: Argument 1 to "_parse_letter_version" has incompatible type "str | None"; expected "str"  [arg-type]
+ sklearn/externals/_packaging/version.py:305: error: Argument 2 to "_parse_letter_version" has incompatible type "str | None"; expected "str | bytes | SupportsInt"  [arg-type]
+ sklearn/externals/_packaging/version.py:307: error: Argument 1 to "_parse_letter_version" has incompatible type "str | None"; expected "str"  [arg-type]
+ sklearn/externals/_packaging/version.py:307: error: Argument 2 to "_parse_letter_version" has incompatible type "str | None"; expected "str | bytes | SupportsInt"  [arg-type]
+ sklearn/externals/_packaging/version.py:308: error: Argument 1 to "_parse_local_version" has incompatible type "str | None"; expected "str"  [arg-type]

aioredis (https://github.com/aio-libs/aioredis)
+ aioredis/client.py:3903: error: Argument 1 to "findall" of "Pattern" has incompatible type "str | None"; expected "str"  [arg-type]
+ aioredis/client.py:3913: error: Item "None" of "str | None" has no attribute "startswith"  [union-attr]
+ aioredis/client.py:3915: error: Value of type "str | None" is not indexable  [index]
+ aioredis/client.py:3919: error: Item "None" of "str | None" has no attribute "rsplit"  [union-attr]
+ aioredis/client.py:3923: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]

websockets (https://github.com/aaugustin/websockets)
+ src/websockets/version.py:60: error: Item "None" of "str | None" has no attribute "replace"  [union-attr]
+ src/websockets/version.py:80: error: Incompatible return value type (got "str | None", expected "str")  [return-value]

spack (https://github.com/spack/spack)
+ lib/spack/llnl/util/argparsewriter.py:128: error: Item "None" of "Optional[str]" has no attribute "split"  [union-attr]
+ lib/spack/spack/detection/common.py:252: error: Incompatible return value type (got "Optional[str]", expected "str")  [return-value]
+ lib/spack/spack/cmd/commands.py:777: error: Item "None" of "Optional[str]" has no attribute "strip"  [union-attr]
+ lib/spack/spack/cmd/checksum.py:225: error: Argument 1 to "Version" has incompatible type "Optional[str]"; expected "Union[str, int]"  [arg-type]
+ lib/spack/spack/cmd/checksum.py:239: error: Argument 1 to "Version" has incompatible type "Optional[str]"; expected "Union[str, int]"  [arg-type]

werkzeug (https://github.com/pallets/werkzeug)
+ src/werkzeug/http.py:379: error: Incompatible types in assignment (expression has type "Optional[str]", variable has type "str")  [assignment]
+ src/werkzeug/http.py:380: error: Item "None" of "Optional[str]" has no attribute "lower"  [union-attr]
+ src/werkzeug/http.py:516: error: Item "None" of "Optional[str]" has no attribute "lower"  [union-attr]
+ src/werkzeug/http.py:949: error: Argument 1 to "ETags" has incompatible type "List[Optional[str]]"; expected "Optional[Iterable[str]]"  [arg-type]
+ src/werkzeug/http.py:949: error: Argument 2 to "ETags" has incompatible type "List[Optional[str]]"; expected "Optional[Iterable[str]]"  [arg-type]
+ src/werkzeug/sansio/http.py:117: error: Argument 1 to "len" has incompatible type "Optional[bytes]"; expected "Sized"  [arg-type]
+ src/werkzeug/sansio/http.py:118: error: Incompatible return value type (got "Optional[bytes]", expected "bytes")  [return-value]
+ src/werkzeug/sansio/http.py:120: error: Argument 1 to "int" has incompatible type "Optional[bytes]"; expected "Union[str, bytes, bytearray]"  [arg-type]
+ src/werkzeug/sansio/multipart.py:153: error: Item "None" of "Optional[bytes]" has no attribute "startswith"  [union-attr]
+ src/werkzeug/sansio/multipart.py:264: error: Item "None" of "Optional[bytes]" has no attribute "startswith"  [union-attr]
+ src/werkzeug/routing/rules.py:120: error: Argument 1 to "_pythonize" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ src/werkzeug/routing/rules.py:127: error: Incompatible return value type (got "Tuple[Tuple[Any, ...], Dict[Optional[str], Union[None, int, float, str]]]", expected "Tuple[Tuple[Any, ...], Dict[str, Any]]")  [return-value]
+ src/werkzeug/routing/matcher.py:147: error: Unsupported operand types for + ("List[str]" and "List[Optional[str]]")  [operator]
+ src/werkzeug/routing/map.py:637: error: Invalid index type "Optional[str]" for "MutableMapping[str, Any]"; expected type "str"  [index]
+ src/werkzeug/routing/map.py:638: error: Invalid index type "Optional[str]" for "Dict[str, BaseConverter]"; expected type "str"  [index]

poetry (https://github.com/python-poetry/poetry)
+ src/poetry/utils/wheel.py:30: error: Item "None" of "str | None" has no attribute "replace"  [union-attr]
+ src/poetry/utils/wheel.py:31: error: Item "None" of "str | None" has no attribute "replace"  [union-attr]
+ src/poetry/utils/wheel.py:33: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ src/poetry/utils/wheel.py:34: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ src/poetry/utils/wheel.py:35: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ src/poetry/config/config.py:205: error: Item "None" of "str | None" has no attribute "lower"  [union-attr]
+ src/poetry/config/config.py:261: error: Argument 1 to "get" of "Config" has incompatible type "str | None"; expected "str"  [arg-type]
+ src/poetry/utils/dependency_specification.py:85: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ src/poetry/utils/dependency_specification.py:202: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ src/poetry/utils/dependency_specification.py:213: error: Incompatible types in assignment (expression has type "str | None", variable has type "str")  [assignment]
+ src/poetry/utils/dependency_specification.py:216: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ src/poetry/utils/dependency_specification.py:220: error: Incompatible types in assignment (expression has type "str | None", target has type "str | bool | dict[str, str | bool] | list[str]")  [assignment]
+ src/poetry/utils/dependency_specification.py:224: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ src/poetry/puzzle/provider.py:717: error: Argument 2 to "match" has incompatible type "str | None"; expected "str"  [arg-type]
+ src/poetry/puzzle/provider.py:760: error: Argument 2 to "match" has incompatible type "str | None"; expected "str"  [arg-type]
+ src/poetry/installation/chooser.py:170: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ src/poetry/console/commands/config.py:202: error: Argument 1 to "delete_http_password" of "PasswordManager" has incompatible type "str | None"; expected "str"  [arg-type]
+ src/poetry/console/commands/config.py:204: error: Argument 1 to "delete_pypi_token" of "PasswordManager" has incompatible type "str | None"; expected "str"  [arg-type]
+ src/poetry/console/commands/config.py:223: error: Argument 1 to "set_http_password" of "PasswordManager" has incompatible type "str | None"; expected "str"  [arg-type]
+ src/poetry/console/commands/config.py:232: error: Argument 1 to "set_pypi_token" of "PasswordManager" has incompatible type "str | None"; expected "str"  [arg-type]

spark (https://github.com/apache/spark)
+ python/pyspark/util.py:70: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ python/pyspark/sql/types.py:1403: error: Argument 1 to "int" has incompatible type "str | Any | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ python/pyspark/sql/types.py:1403: note: Error code "arg-type" not covered by "type: ignore" comment
+ python/pyspark/sql/types.py:1407: error: Argument 1 to "get" of "dict" has incompatible type "str | Any | None"; expected "str"  [arg-type]
+ python/pyspark/sql/types.py:1407: note: Error code "arg-type" not covered by "type: ignore" comment
+ python/pyspark/sql/types.py:1408: error: Argument 1 to "get" of "dict" has incompatible type "str | Any | None"; expected "str"  [arg-type]
+ python/pyspark/sql/types.py:1408: note: Error code "arg-type" not covered by "type: ignore" comment
+ python/pyspark/sql/types.py:1415: error: Argument 1 to "get" of "dict" has incompatible type "str | Any | None"; expected "str"  [arg-type]
+ python/pyspark/sql/types.py:1415: note: Erro

... (truncated 241 lines) ...

@AlexWaygood
Copy link
Member

Thanks for the PR! Unfortunately, this has been tried many times before, and as you can see, it would be far too disruptive for us to be able to consider merging this.

We could probably document this better. Might you be interested in changing your PR so that it just adds an explanatory comment about why we have the annotations the way they currently are?

@KotlinIsland
Copy link
Contributor

Basedmypy works correctly in these cases:

import re

s: str
if m := re.match("a(b)?(c)", s):
    reveal_type(m.groups())  #  (str | None, str)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants