Skip to content

Fix(stdlib/re): Return AnyStr | None for regex groups #11203

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

danjones1618
Copy link

The group of a Match object will return either the matching string or None if the group did not match.

Relevent documentation:

Copy link
Contributor

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

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]

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 "str | Buffer | SupportsFloat | SupportsIndex"  [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 "str | Buffer | SupportsFloat | SupportsIndex"  [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 "str | Buffer | SupportsFloat | SupportsIndex"  [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]

parso (https://github.com/davidhalter/parso)
+ parso/utils.py:168: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ parso/utils.py:179: error: Incompatible types in assignment (expression has type "int", variable has type "str | None")  [assignment]
+ parso/utils.py:180: error: Argument 2 to "PythonVersionInfo" has incompatible type "str"; expected "int"  [arg-type]

paroxython (https://github.com/laowantong/paroxython)
+ paroxython/flatten_ast.py:480: error: Item "None" of "Any | None" has no attribute "startswith"  [union-attr]
+ paroxython/flatten_ast.py:484: error: Item "None" of "Any | None" has no attribute "startswith"  [union-attr]
+ paroxython/flatten_ast.py:516: error: Argument 1 to "int" has incompatible type "Any | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]

porcupine (https://github.com/Akuli/porcupine)
+ porcupine/plugins/geometry.py:17: error: Argument 1 to "map" has incompatible type "type[int]"; expected "Callable[[str | None], int]"  [arg-type]
+ porcupine/plugins/editorconfig.py:163: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ porcupine/plugins/editorconfig.py:164: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ porcupine/plugins/editorconfig.py:178: error: Argument 1 to "map" has incompatible type "type[int]"; expected "Callable[[str | None], int]"  [arg-type]
+ porcupine/plugins/aboutdialog.py:23: error: Argument 1 to "Path" has incompatible type "str | None"; expected "str | PathLike[str]"  [arg-type]
+ porcupine/plugins/aboutdialog.py:86: error: Argument 3 to "replace" of "Text" has incompatible type "str | None"; expected "str"  [arg-type]
+ porcupine/plugins/langserver.py:444: error: Argument 1 to "len" has incompatible type "str | None"; expected "Sized"  [arg-type]

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:442: 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:52: error: Incompatible return value type (got "tuple[str | None, str | None]", expected "tuple[str, str | None]")  [return-value]

stone (https://github.com/dropbox/stone)
+ stone/backend.py:347: error: Argument 1 has incompatible type "str | None"; expected "str"  [arg-type]
+ stone/backend.py:347: error: Argument 2 has incompatible type "str | None"; expected "str"  [arg-type]

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

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:634: error: Argument 1 to "BBCodeTag" has incompatible type "str | None"; expected "str"  [arg-type]
+ steam/utils.py:636: error: Argument 1 to "findall" of "Pattern" has incompatible type "str | None"; expected "str"  [arg-type]
+ steam/utils.py:637: error: Argument 4 to "BBCodeTag" has incompatible type "str | None"; expected "str"  [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/models.py:90: error: Item "None" of "str | None" has no attribute "replace"  [union-attr]
+ steam/models.py:91: error: Item "None" of "str | None" has no attribute "replace"  [union-attr]
+ steam/models.py:93: error: Incompatible types in assignment (expression has type "str | None", variable has type "float | str")  [assignment]
+ steam/models.py:94: error: Incompatible types in assignment (expression has type "str | None", variable has type "float | str")  [assignment]
+ steam/http.py:350: 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:98: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ steam/ext/csgo/client.py:102: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ steam/ext/csgo/client.py:103: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ steam/ext/csgo/client.py:104: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]

mkdocs (https://github.com/mkdocs/mkdocs)
+ mkdocs/utils/meta.py:67: error: Argument 1 to "load" has incompatible type "str | None"; expected "str | bytes | SupportsRead[str] | SupportsRead[bytes]"  [arg-type]
+ mkdocs/utils/meta.py:86: error: Item "None" of "str | None" has no attribute "lower"  [union-attr]
+ mkdocs/utils/meta.py:87: error: Item "None" of "str | None" has no attribute "strip"  [union-attr]
+ mkdocs/utils/meta.py:96: error: Item "None" of "str | None" has no attribute "strip"  [union-attr]
+ mkdocs/livereload/__init__.py:271: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ mkdocs/tests/build_tests.py:884: error: Argument 2 to "Path" has incompatible type "str | None"; expected "str | PathLike[str]"  [arg-type]

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

pyjwt (https://github.com/jpadilla/pyjwt)
+ jwt/utils.py:153: error: Value of type "bytes | None" is not indexable  [index]

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]

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]

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:112: error: Incompatible types in assignment (expression has type "str | Any | None", variable has type "str")  [assignment]
+ pydantic/errors.py:112: 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 "str | Buffer | SupportsFloat | SupportsIndex"  [arg-type]
+ pydantic/v1/networks.py:442: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ pydantic/v1/networks.py:728: error: Incompatible types in assignment (expression has type "str | None", variable has type "str")  [assignment]
+ pydantic/types.py:1784: error: Argument 1 to "float" has incompatible type "str | None"; expected "str | Buffer | SupportsFloat | SupportsIndex"  [arg-type]
+ pydantic/networks.py:690: 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]

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 "str | Buffer | SupportsFloat | SupportsIndex"  [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:1043: error: Incompatible types in assignment (expression has type "str | None", variable has type "str")  [assignment]
+ pandas/core/dtypes/dtypes.py:1919: error: Incompatible return value type (got "tuple[str | None, bool]", expected "tuple[str, bool]")  [return-value]
+ pandas/core/interchange/from_dataframe.py:340: error: Unsupported left operand type for + ("None")  [operator]
+ pandas/core/interchange/from_dataframe.py:340: note: Left operand is of type "str | None"

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

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]

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/http/headers.py:56: error: Item "None" of "bytes | None" has no attribute "decode"  [union-attr]
+ mitmproxy/net/http/headers.py:62: error: Item "None" of "bytes | None" has no attribute "decode"  [union-attr]
+ 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]

sympy (https://github.com/sympy/sympy)
+ sympy/core/expr.py:377: 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:1270: error: Argument 1 to "len" has incompatible type "str | None"; expected "Sized"  [arg-type]
+ rich/text.py:1317: 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:184: 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]

aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/cookiejar.py:352:57: error: Argument 1 to "match" of "Pattern" has incompatible type "str | None"; expected "str"  [arg-type]
+ aiohttp/cookiejar.py:355:49: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ aiohttp/cookiejar.py:359:60: error: Argument 1 to "match" of "Pattern" has incompatible type "str | None"; expected "str"  [arg-type]
+ aiohttp/cookiejar.py:366:55: error: Argument 1 to "match" of "Pattern" has incompatible type "str | None"; expected "str"  [arg-type]
+ aiohttp/cookiejar.py:374:53: error: Argument 1 to "match" of "Pattern" has incompatible type "str | None"; expected "str"  [arg-type]
+ aiohttp/http_websocket.py:211:36: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ aiohttp/http_websocket.py:225:36: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ aiohttp/http_websocket.py:238:36: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ aiohttp/http_websocket.py:238:36: note: Possible overload variants:
+ aiohttp/http_websocket.py:238:36: note:     def __add__(self, str, /) -> str
+ aiohttp/http_websocket.py:238:36: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-operator for more info
+ aiohttp/http_websocket.py:238:36: note: Right operand is of type "str | None"
+ aiohttp/http_parser.py:569:37: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ aiohttp/http_parser.py:677:37: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ aiohttp/client_reqrep.py:867:22: error: Item "None" of "str | None" has no attribute "split"  [union-attr]
+ aiohttp/client_reqrep.py:867:22: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-union-attr for more info
+ aiohttp/client_reqrep.py:878:26: error: Argument 1 to "add" of "MultiDict" has incompatible type "str | None"; expected "str | istr"  [arg-type]
+ aiohttp/client_reqrep.py:878:31: error: Argument 2 to "add" of "MultiDict" has incompatible type "str | None"; expected "str | URL"  [arg-type]
+ aiohttp/client_reqrep.py:880:19: error: Incompatible types in assignment (expression has type "str | URL | None", variable has type "str | None")  [assignment]
+ aiohttp/client_reqrep.py:882:47: error: Argument 1 to "URL" has incompatible type "str | None"; expected "str | URL"  [arg-type]
+ aiohttp/web_response.py:280: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]

mypy (https://github.com/python/mypy)
+ mypy/util.py:123: error: Item "None" of "Optional[bytes]" has no attribute "decode"  [union-attr]
+ mypy/util.py:123: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-union-attr for more info
+ mypy/stubdoc.py:400: error: Item "None" of "Optional[str]" has no attribute "split"  [union-attr]
+ mypy/stubdoc.py:402: error: Item "None" of "Optional[str]" has no attribute "strip"  [union-attr]
+ mypy/stubdoc.py:406: error: Item "None" of "Optional[str]" has no attribute "split"  [union-attr]
+ mypy/config_parser.py:47: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ mypy/fastparse.py:271: error: Item "None" of "Optional[str]" has no attribute "split"  [union-attr]
+ mypy/test/data.py:145: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ mypy/test/data.py:148: error: Argument 2 has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ mypy/test/data.py:349: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ mypy/test/data.py:549: error: Item "None" of "Optional[str]" has no attribute "replace"  [union-attr]
+ mypy/test/data.py:567: error: Item "None" of "Optional[str]" has no attribute "replace"  [union-attr]
+ mypy/test/data.py:579: error: Item "None" of "Optional[str]" has no attribute "replace"  [union-attr]
+ mypy/test/data.py:691: error: Argument 1 to "add_test_name_suffix" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ mypy/test/update_data.py:32: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ mypy/test/update_data.py:35: error: Invalid index type "Tuple[Optional[str], int]" for "Dict[Tuple[str, int], List[Tuple[str, str]]]"; expected type "Tuple[str, int]"  [index]
+ mypy/test/update_data.py:35: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-index for more info
+ mypy/test/update_data.py:35: error: Argument 1 to "append" of "list" has incompatible type "Tuple[Optional[str], Optional[str]]"; expected "Tuple[str, str]"  [arg-type]
+ mypy/test/helpers.py:346: error: Item "None" of "Optional[str]" has no attribute "split"  [union-attr]
+ mypy/test/teststubgen.py:733: error: Item "None" of "Optional[str]" has no attribute "split"  [union-attr]
+ mypy/test/teststubgen.py:756: error: Item "None" of "Optional[str]" has no attribute "split"  [union-attr]
+ mypy/test/testpythoneval.py:63: error: Item "None" of "Optional[str]" has no attribute "split"  [union-attr]
+ mypy/test/testpep561.py:176: error: Item "None" of "Optional[str]" has no attribute "split"  [union-attr]
+ mypy/test/testfinegrained.py:193: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ mypy/test/testfinegrained.py:283: error: Item "None" of "Optional[str]" has no attribute "strip"  [union-attr]
+ mypy/test/testfinegrained.py:300: error: Argument 1 to "float" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsFloat, SupportsIndex]"  [arg-type]
+ mypy/test/testfinegrained.py:304: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ mypy/test/testfinegrained.py:336: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ mypy/test/testfinegrained.py:343: error: Argument 1 to "cmd_inspect" of "Server" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ mypy/test/testcmdline.py:137: error: Item "None" of "Optional[str]" has no attribute "split"  [union-attr]
+ mypy/test/testcheck.py:72: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ mypy/test/testcheck.py:260: error: Incompatible return value type (got "Set[Optional[str]]", expected "Set[str]")  [return-value]
+ mypy/test/testcheck.py:311: error: Item "None" of "Optional[str]" has no attribute "split"  [union-attr]
+ mypyc/test/testutil.py:194: error: Incompatible return value type (got "List[Optional[str]]", expected "List[str]")  [return-value]
+ mypyc/test/testutil.py:279: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ mypyc/test/test_commandline.py:38: error: Item "None" of "Optional[str]" has no attribute "split"  [union-attr]
+ mypyc/test/test_run.py:364: error: Argument 1 to "literal_eval" has incompatible type "Optional[str]"; expected "Union[str, AST]"  [arg-type]
+ mypyc/test/test_run.py:419: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ mypyc/test/test_run.py:423: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [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]

trio (https://github.com/python-trio/trio)
+ src/trio/_tools/mypy_annotate.py:56: error: Argument "filename" to "Result" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ src/trio/_tools/mypy_annotate.py:57: error: Argument 1 to "int" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsInt, SupportsIndex, SupportsTrunc]"  [arg-type]
+ src/trio/_tools/mypy_annotate.py:61: error: Invalid index type "Optional[str]" for "Dict[str, str]"; expected type "str"  [index]
+ src/trio/_tools/mypy_annotate.py:62: error: Argument "message" to "Result" has incompatible type "Optional[str]"; expected "str"  [arg-type]
+ src/trio/_tests/test_file_io.py:119: error: Argument 1 to "append" of "list" has incompatible type "Tuple[Optional[str], str]"; expected "Tuple[str, str]"  [arg-type]

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[str, Buffer, SupportsFloat, SupportsIndex]"  [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:3549: 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:3061: 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:267: 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:1078: 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[str, Buffer, SupportsFloat, SupportsIndex]"  [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[str, Buffer, SupportsFloat, SupportsIndex]"  [arg-type]
+ sphinx/writers/latex.py:274:46: error: Argument 1 to "float" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsFloat, SupportsIndex]"  [arg-type]
+ sphinx/writers/latex.py:276:30: error: Argument 1 to "float" has incompatible type "Optional[str]"; expected "Union[str, Buffer, SupportsFloat, SupportsIndex]"  [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[str, Buffer, SupportsFloat, SupportsIndex]"  [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[str, Buffer, SupportsFloat, SupportsIndex]"  [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]

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/catalog/add_book/match.py: note: In function "mk_norm":
+ openlibrary/catalog/add_book/match.py:86: error: Incompatible types in assignment (expression has type "str | None", variable has type "str")  [assignment]
+ openlibrary/catalog/add_book/match.py: note: In function "build_titles":
+ openlibrary/catalog/add_book/match.py:179: error: Argument 1 to "append" of "list" has incompatible type "str | None"; expected "str"  [arg-type]
+ openlibrary/catalog/add_book/match.py:180: error: Argument 1 to "strip_articles" has incompatible type "str | None"; expected "str"  [arg-type]
+ 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/catalog/utils/__init__.py: note: In function "flip_name":
+ openlibrary/catalog/utils/__init__.py:81: error: Unsupported left operand type for + ("None")  [operator]
+ openlibrary/catalog/utils/__init__.py:81: note: Left operand is of type "str | None"
+ openlibrary/catalog/utils/__init__.py:81: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ openlibrary/catalog/utils/__init__.py:81: note: Possible overload variants:
+ openlibrary/catalog/utils/__init__.py:81: note:     def __add__(self, str, /) -> str
+ openlibrary/catalog/utils/__init__.py:81: note: Both left and right operands are unions
+ openlibrary/catalog/marc/get_subjects.py: note: In function "flip_subject":
+ openlibrary/catalog/marc/get_subjects.py:30: error: Unsupported left operand type for + ("None")  [operator]
+ openlibrary/catalog/marc/get_subjects.py:30: note: Left operand is of type "str | None"
+ openlibrary/catalog/marc/get_subjects.py:30: error: No overload variant of "__add__" of "str" matches argument type "None"  [operator]
+ openlibrary/catalog/marc/get_subjects.py:30: note: Possible overload variants:
+ openlibrary/catalog/marc/get_subjects.py:30: note:     def __add__(self, str, /) -> str
+ openlibrary/catalog/marc/get_subjects.py:30: note: Both left and right operands are unions
+ openlibrary/catalog/marc/get_subjects.py:30: error: Item "None" of "str | None" has no attribute "lower"  [union-attr]
+ openlibrary/catalog/marc/get_subjects.py: note: In function "tidy_subject":
+ openlibrary/catalog/marc/get_subjects.py:40: error: Incompatible return value type (got "str | None", expected "str")  [return-value]
+ 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/status.py: note: In member "pull_id" of class "PRStatus":
+ openlibrary/plugins/openlibrary/status.py:75: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ 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/updater/edition.py: note: In member "language" of class "EditionSolrBuilder":
+ openlibrary/solr/updater/edition.py:144: error: Argument 1 to "append" of "list" has incompatible type "str | None"; expected "str"  [arg-type]
+ openlibrary/solr/updater/edition.py: note: In member "publish_year" of class "EditionSolrBuilder":
+ openlibrary/solr/updater/edition.py:197: error: Argument 1 to "int" has incompatible type "str | None"; expected "str | Buffer | SupportsInt | SupportsIndex | SupportsTrunc"  [arg-type]
+ openlibrary/solr/updater/work.py: note: In function "extract_edition_olid":
+ openlibrary/solr/updater/work.py:217: error: Incompatible return value type (got "str | None", expected "str")  [return-value]
+ openlibrary/solr/updater/work.py: note: In member "author_key" of class "WorkSolrBuilder":
+ openlibrary/solr/updater/work.py:625: error: List comprehension has incompatible type List[str | None]; expected List[str]  [misc]

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

CPython (Argument Clinic) (https://github.com/python/cpython)
+ Tools/clinic/clinic.py:5487: error: Incompatible types in assignment (expression has type "str | None", variable has type "str")  [assignment]
+ Tools/clinic/clinic.py:5488: error: Argument 1 to "parse_version" of "DSLParser" has incompatible type "str | None"; expected "str"  [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 in

... (truncated 327 lines) ...

@danjones1618
Copy link
Author

Oops duplicates #9482 which was closed for being potentially too disruptive from the mypy primer output.
A year later, it's just as disruptive so closing

@AlexWaygood
Copy link
Member

AlexWaygood commented Dec 26, 2023

Thanks; however, this is a duplicate of #10680, #9482, and many others (see also #9465 (comment), python/mypy#16441 (comment), #10526, etc.)

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.

2 participants