Repository navigation
fix Variable type is not narrowed after "if" containing both call to "Never-returning" function and "raise" #5186 - #5192
Open
asukaminato0721 wants to merge 2 commits into
Open
asukaminato0721 wants to merge 2 commits into
asukaminato0721 wants to merge 2 commits into
Conversation
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D124568673. (Because this pull request was imported automatically, there will not be any future comments.) |
|
Diff from mypy_primer, showing the effect of this PR on open source code: ============================================================
SUMMARY
============================================================
Total: +64 new errors, -62 fixed errors
By preset: +6/-34 (default), +30/-35 (strict)
Projects with changes (32):
pip: +6 -1
cloud-init: +1 -10
egglog-python: +0 -1
rotki: +4 -0
bokeh: +0 -1
pytest: +0 -1
jax: +4 -2
twine: +0 -1
aiortc: +2 -0
scikit-learn: +2 -5
freqtrade: +0 -1
pwndbg: +11 -2
setuptools: +1 -1
apprise: +2 -0
mongo-python-driver: +4 -3
schemathesis: +4 -4
beartype: +1 -1
stone: +10 -2
pandera: +0 -1
hydpy: +0 -1
pandas: +0 -1
dd-trace-py: +1 -0
mypy: +0 -1
meson: +3 -6
ecosystem-analyzer: +1 -0
core: +3 -8
paasta: +0 -1
jinja: +0 -1
sphinx: +2 -1
xarray: +0 -2
spack: +0 -1
scrapy: +2 -2
============================================================
FULL DIFF DETAILS
------------------------------------------------------------
pip (https://github.com/pypa/pip)
- ERROR src/pip/_internal/resolution/resolvelib/resolver.py:302:16-22: Implicit conversion of `set[str]` to `bool` is not allowed [implicit-bool]
+ ERROR src/pip/_internal/resolution/resolvelib/resolver.py:302:16-22: Implicit conversion of `set[Unknown]` to `bool` is not allowed [implicit-bool]
+ ERROR src/pip/_internal/resolution/resolvelib/resolver.py:307:13-17: The type of `leaf` is unknown; it is inferred as an implicit `Any` [unknown-variable-type]
+ ERROR src/pip/_internal/resolution/resolvelib/resolver.py:308:16-20: The type of this argument is unknown [unknown-argument-type]
+ ERROR src/pip/_internal/resolution/resolvelib/resolver.py:310:21-25: The type of this argument is unknown [unknown-argument-type]
+ ERROR src/pip/_internal/resolution/resolvelib/resolver.py:312:13-17: The type of `leaf` is unknown; it is inferred as an implicit `Any` [unknown-variable-type]
+ ERROR src/pip/_internal/resolution/resolvelib/resolver.py:313:26-30: The type of this argument is unknown [unknown-argument-type]
cloud-init (https://github.com/canonical/cloud-init)
- ERROR cloudinit/config/cc_apt_configure.py:399:13-17: The type of `line` is unknown; it is inferred as an implicit `Any` [unknown-variable-type]
- ERROR cloudinit/config/cc_apt_configure.py:399:28-38: The type of attribute `splitlines` is unknown; it is inferred as an implicit `Any` [unknown-attribute-access]
- ERROR cloudinit/config/cc_apt_configure.py:400:21-31: The type of attribute `startswith` is unknown; it is inferred as an implicit `Any` [unknown-attribute-access]
- ERROR cloudinit/config/cc_apt_configure.py:407:20-32: The type of `cols` is unknown; it is inferred as an implicit `Any` [unknown-variable-type]
- ERROR cloudinit/config/cc_apt_configure.py:407:25-30: The type of attribute `split` is unknown; it is inferred as an implicit `Any` [unknown-attribute-access]
- ERROR cloudinit/config/cc_apt_configure.py:408:20-24: The type of this argument is unknown [unknown-argument-type]
- ERROR cloudinit/config/cc_apt_configure.py:410:28-38: The type of attribute `startswith` is unknown; it is inferred as an implicit `Any` [unknown-attribute-access]
- ERROR cloudinit/config/cc_apt_configure.py:411:25-28: The type of `col` is unknown; it is inferred as an implicit `Any` [unknown-variable-type]
- ERROR cloudinit/config/cc_apt_configure.py:413:32-40: The type of attribute `endswith` is unknown; it is inferred as an implicit `Any` [unknown-attribute-access]
- ERROR cloudinit/config/cc_apt_configure.py:417:28-71: The type of `line` is unknown; it is inferred as an implicit `Any` [unknown-variable-type]
+ ERROR cloudinit/config/cc_disk_setup.py:378:20-22: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
egglog-python (https://github.com/egraphs-good/egglog-python)
- ERROR python/egglog/egraph.py:2817:24-35: Argument `BaseExpr | Fact` is not assignable to parameter `expr` with type `BaseExpr` in function `expr_action` [bad-argument-type]
rotki (https://github.com/rotki/rotki)
+ ERROR rotkehlchen/chain/evm/decoding/balancer/v3/decoder.py:174:24-26: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
+ ERROR rotkehlchen/exchanges/bitstamp.py:304:29-31: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
+ ERROR rotkehlchen/exchanges/bitstamp.py:324:13-16: The type of `idx` is unknown; it is inferred as an implicit `Any` [unknown-variable-type]
+ ERROR rotkehlchen/exchanges/bitstamp.py:325:40-43: The type of this argument is unknown [unknown-argument-type]
bokeh (https://github.com/bokeh/bokeh)
- ERROR src/bokeh/command/bootstrap.py:120:8-11: `ret` may be uninitialized [unbound-name]
pytest (https://github.com/pytest-dev/pytest)
- ERROR src/_pytest/doctest.py:585:33-39: `module` may be uninitialized [unbound-name]
jax (https://github.com/google/jax)
+ ERROR jax/_src/array.py:1251:10-12: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
- ERROR jax/_src/lax/control_flow/loops.py:657:44-50: The type of this argument is unknown [unknown-argument-type]
- ERROR jax/_src/pallas/triton/lowering.py:2625:49-50: The type of this argument is unknown [unknown-argument-type]
+ ERROR jax/_src/pjit.py:1912:3-36: Unused `# pyrefly: ignore` comment for code(s): unbound-name [unused-ignore]
+ ERROR jax/experimental/mosaic/gpu/profiler.py:280:14-16: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
+ ERROR jax/experimental/mosaic/gpu/profiler.py:340:43-53: The return type of this lambda is unknown; it is inferred as an implicit `Any` [unknown-return-type]
twine (https://github.com/pypa/twine)
- ERROR twine/repository.py:161:16-20: `resp` may be uninitialized [unbound-name]
aiortc (https://github.com/aiortc/aiortc)
+ ERROR src/aiortc/rtcpeerconnection.py:86:14-16: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
+ ERROR src/aiortc/rtp.py:534:18-20: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
scikit-learn (https://github.com/scikit-learn/scikit-learn)
- ERROR sklearn/utils/_pprint.py:267:24-29: String literal used as condition. It's equivalent to `False` [redundant-condition]
- ERROR sklearn/utils/_pprint.py:267:24-29: Implicit conversion of `Literal['']` to `bool` is not allowed [implicit-bool]
+ ERROR sklearn/utils/_pprint.py:267:24-29: Implicit conversion of `Literal['', ', '] | Unknown` to `bool` is not allowed [implicit-bool]
- ERROR sklearn/utils/_pprint.py:318:24-29: String literal used as condition. It's equivalent to `False` [redundant-condition]
- ERROR sklearn/utils/_pprint.py:318:24-29: Implicit conversion of `Literal['']` to `bool` is not allowed [implicit-bool]
+ ERROR sklearn/utils/_pprint.py:318:24-29: Implicit conversion of `Literal['', ', '] | Unknown` to `bool` is not allowed [implicit-bool]
- ERROR sklearn/utils/multiclass.py:422:17-33: `first_row_or_val` may be uninitialized [unbound-name]
freqtrade (https://github.com/freqtrade/freqtrade)
- ERROR freqtrade/exchange/exchange.py:3926:31-40: `max_stake` may be uninitialized [unbound-name]
pwndbg (https://github.com/pwndbg/pwndbg)
- ERROR pwndbg/aglib/kernel/kallsyms.py:129:45-48: `pos` may be uninitialized [unbound-name]
+ ERROR pwndbg/aglib/kernel/kallsyms.py:114:22-24: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
+ ERROR pwndbg/aglib/kernel/kallsyms.py:115:28-30: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
+ ERROR pwndbg/aglib/kernel/kallsyms.py:139:20-33: The type of `position` is unknown; it is inferred as an implicit `Any` [unknown-variable-type]
+ ERROR pwndbg/aglib/kernel/kallsyms.py:149:39-47: The type of this argument is unknown [unknown-argument-type]
+ ERROR pwndbg/aglib/kernel/kallsyms.py:149:76-84: The type of this argument is unknown [unknown-argument-type]
+ ERROR pwndbg/aglib/kernel/kallsyms.py:159:16-24: Returning implicit Any from function declared to return "int" [no-any-return-implicit]
+ ERROR pwndbg/aglib/kernel/kmod.py:219:14-16: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
+ ERROR pwndbg/aglib/kernel/ktask.py:694:60-79: `+` is not supported between `int` and `None` [unsupported-operation]
+ ERROR pwndbg/aglib/kernel/ktask.py:695:58-76: `+` is not supported between `int` and `None` [unsupported-operation]
+ ERROR pwndbg/aglib/kernel/ktask.py:721:12-33: Returned type `tuple[str, int | None]` is not assignable to declared return type `tuple[str, int]` [bad-return]
- ERROR pwndbg/aglib/kernel/ktask.py:940:11-17: Implicit conversion of `Value` to `bool` is not allowed [implicit-bool]
+ ERROR pwndbg/aglib/kernel/ktask.py:940:11-17: Implicit conversion of `Value | None` to `bool` is not allowed [implicit-bool]
setuptools (https://github.com/pypa/setuptools)
- ERROR setuptools/_distutils/dist.py:530:15-19: Implicit conversion of `Sequence[str] | tuple[Sequence[str], OptionDummy | Unknown]` to `bool` is not allowed [implicit-bool]
+ ERROR setuptools/_distutils/dist.py:530:15-19: Implicit conversion of `Sequence[str] | tuple[Sequence[str], OptionDummy | Unknown] | Unknown` to `bool` is not allowed [implicit-bool]
apprise (https://github.com/caronc/apprise)
+ ERROR apprise/conversion/commonmark.py:1678:20-22: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
+ ERROR apprise/conversion/commonmark.py:1688:17-45: The type of `bound` is unknown; it is inferred as an implicit `Any` [unknown-variable-type]
mongo-python-driver (https://github.com/mongodb/mongo-python-driver)
- ERROR pymongo/asynchronous/_kms_connect.py:87:19-39: Expected a callable, got `None` [not-callable]
- ERROR pymongo/synchronous/_kms_connect.py:87:19-39: Expected a callable, got `None` [not-callable]
+ ERROR tools/ensure_future_annotations_import.py:23:11-13: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
- ERROR tools/ensure_future_annotations_import.py:37:4-11: Implicit conversion of `list[Path]` to `bool` is not allowed [implicit-bool]
+ ERROR tools/ensure_future_annotations_import.py:37:4-11: Implicit conversion of `list[Unknown]` to `bool` is not allowed [implicit-bool]
+ ERROR tools/ensure_future_annotations_import.py:39:9-13: The type of `item` is unknown; it is inferred as an implicit `Any` [unknown-variable-type]
+ ERROR tools/ensure_future_annotations_import.py:40:15-19: The type of this argument is unknown [unknown-argument-type]
schemathesis (https://github.com/schemathesis/schemathesis)
- ERROR src/schemathesis/specs/openapi/coverage/_schema.py:2555:32-40: Implicit conversion of `None` to `bool` is not allowed [implicit-bool]
+ ERROR src/schemathesis/specs/openapi/coverage/_schema.py:2555:32-40: Implicit conversion of `Any | None` to `bool` is not allowed [implicit-bool]
- ERROR src/schemathesis/specs/openapi/coverage/_schema.py:2569:36-44: Implicit conversion of `None` to `bool` is not allowed [implicit-bool]
+ ERROR src/schemathesis/specs/openapi/coverage/_schema.py:2569:36-44: Implicit conversion of `Any | None` to `bool` is not allowed [implicit-bool]
- ERROR src/schemathesis/specs/openapi/coverage/_schema.py:2585:36-44: Implicit conversion of `None` to `bool` is not allowed [implicit-bool]
+ ERROR src/schemathesis/specs/openapi/coverage/_schema.py:2585:36-44: Implicit conversion of `Any | None` to `bool` is not allowed [implicit-bool]
- ERROR src/schemathesis/specs/openapi/coverage/_schema.py:2606:32-40: Implicit conversion of `None` to `bool` is not allowed [implicit-bool]
+ ERROR src/schemathesis/specs/openapi/coverage/_schema.py:2606:32-40: Implicit conversion of `Any | None` to `bool` is not allowed [implicit-bool]
beartype (https://github.com/beartype/beartype)
- ERROR beartype/_check/make/checkmakecls.py:262:20-32: `func_checker` may be uninitialized [unbound-name]
+ ERROR beartype/door/_cls/pep/doorpep484604.py:114:27-29: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
stone (https://github.com/dropbox/stone)
+ ERROR stone/_vendor/ply/yacc.py:2344:20-22: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
+ ERROR stone/_vendor/ply/yacc.py:2345:23-25: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
+ ERROR stone/_vendor/ply/yacc.py:2354:21-23: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
+ ERROR stone/_vendor/ply/yacc.py:2355:24-26: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
- ERROR stone/_vendor/ply/yacc.py:2405:38-40: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
+ ERROR stone/_vendor/ply/yacc.py:2403:17-18: The type of `i` is unknown; it is inferred as an implicit `Any` [unknown-variable-type]
+ ERROR stone/_vendor/ply/yacc.py:2404:20-21: The type of this argument is unknown [unknown-argument-type]
+ ERROR stone/_vendor/ply/yacc.py:2405:33-34: The type of this argument is unknown [unknown-argument-type]
+ ERROR stone/_vendor/ply/yacc.py:2406:29-30: The type of this argument is unknown [unknown-argument-type]
+ ERROR stone/_vendor/ply/yacc.py:2406:32-38: The type of attribute `append` is unknown; it is inferred as an implicit `Any` [unknown-attribute-access]
- ERROR stone/compiler.py:125:28-48: Implicit conversion of `Unknown | None` to `bool` is not allowed [implicit-bool]
+ ERROR stone/compiler.py:125:28-48: Implicit conversion of `None` to `bool` is not allowed [implicit-bool]
pandera (https://github.com/pandera-dev/pandera)
- ERROR tests/pyspark/test_pyspark_container.py:657:32-39: `read_df` may be uninitialized [unbound-name]
hydpy (https://github.com/hydpy-dev/hydpy)
- ERROR hydpy/core/filetools.py:608:16-26: Returned type `str | None` is not assignable to declared return type `str` [bad-return]
pandas (https://github.com/pandas-dev/pandas)
- ERROR pandas/io/json/_json.py:1713:44-50: `record` may be uninitialized [unbound-name]
dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ ERROR ddtrace/aiguard/integrations/strands.py:136:13-15: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
mypy (https://github.com/python/mypy)
- ERROR mypy/semanal.py:8221:17-8229:18: This code is unreachable [unreachable]
meson (https://github.com/mesonbuild/meson)
+ ERROR mesonbuild/dependencies/pkgconfig.py:466:25-27: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
+ ERROR mesonbuild/dependencies/pkgconfig.py:468:21-23: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
- ERROR mesonbuild/dependencies/pkgconfig.py:555:12-25: Implicit conversion of `list[str]` to `bool` is not allowed [implicit-bool]
+ ERROR mesonbuild/dependencies/pkgconfig.py:555:12-25: Implicit conversion of `list[Unknown]` to `bool` is not allowed [implicit-bool]
- ERROR mesonbuild/modules/cmake.py:288:72-73: `p` may be uninitialized [unbound-name]
- ERROR mesonbuild/modules/cmake.py:288:94-100: `stdout` may be uninitialized [unbound-name]
- ERROR mesonbuild/modules/cmake.py:288:110-116: `stderr` may be uninitialized [unbound-name]
- ERROR mesonbuild/modules/codegen.py:355:39-42: `bin` may be uninitialized [unbound-name]
- ERROR mesonbuild/modules/codegen.py:417:40-43: `bin` may be uninitialized [unbound-name]
ecosystem-analyzer (https://github.com/astral-sh/ecosystem-analyzer)
+ ERROR src/ecosystem_analyzer/diagnostic.py:107:26-28: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
core (https://github.com/home-assistant/core)
+ ERROR homeassistant/components/aws_s3/__init__.py:69:16-22: `client` may be uninitialized [unbound-name]
+ ERROR homeassistant/components/cloudflare_r2/__init__.py:72:26-32: `client` may be uninitialized [unbound-name]
+ ERROR homeassistant/components/google_assistant/data_redaction.py:29:14-16: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
- ERROR homeassistant/components/google_assistant/data_redaction.py:36:31-54: Argument `str` is not assignable to parameter `object` with type `Never` in function `list.append` [bad-argument-type]
- ERROR homeassistant/components/google_assistant/data_redaction.py:39:27-30: Argument `str` is not assignable to parameter `object` with type `Never` in function `list.append` [bad-argument-type]
- ERROR homeassistant/components/google_assistant/data_redaction.py:40:12-18: Returned type `list[Never]` is not assignable to declared return type `list[str]` [bad-return]
- ERROR homeassistant/components/notion/coordinator.py:162:29-36: `bridges` may be uninitialized [unbound-name]
- ERROR homeassistant/components/notion/coordinator.py:163:31-40: `listeners` may be uninitialized [unbound-name]
- ERROR homeassistant/components/notion/coordinator.py:164:29-36: `sensors` may be uninitialized [unbound-name]
- ERROR homeassistant/components/notion/coordinator.py:165:38-54: `user_preferences` may be uninitialized [unbound-name]
- ERROR homeassistant/util/loop.py:105:19-36: `integration_frame` may be uninitialized [unbound-name]
paasta (https://github.com/yelp/paasta)
- ERROR paasta_tools/cli/utils.py:442:33-39: `output` may be uninitialized [unbound-name]
jinja (https://github.com/pallets/jinja)
- ERROR src/jinja2/filters.py:730:34-38: `unit` may be uninitialized [unbound-name]
sphinx (https://github.com/sphinx-doc/sphinx)
+ ERROR sphinx/ext/coverage.py:308:21-23: Cannot infer type of empty container; it will be treated as containing `Any` [implicit-any-empty-container]
- ERROR sphinx/util/docstrings.py:28:16-48: Implicit conversion of `Literal[True] | None` to `bool` is not allowed [implicit-bool]
+ ERROR sphinx/util/docstrings.py:28:16-48: Implicit conversion of `bool | None` to `bool` is not allowed [implicit-bool]
xarray (https://github.com/pydata/xarray)
- ERROR xarray/plot/dataarray_plot.py:333:12-20: `plotfunc` may be uninitialized [unbound-name]
- ERROR xarray/structure/combine.py:261:13-25: The type of this argument is unknown [unknown-argument-type]
spack (https://github.com/spack/spack)
- ERROR lib/spack/spack/config.py:1089:23-31: `existing` may be uninitialized [unbound-name]
scrapy (https://github.com/scrapy/scrapy)
- ERROR docs/utils/linkfix.py:53:24-33: Implicit conversion of `None` to `bool` is not allowed [implicit-bool]
+ ERROR docs/utils/linkfix.py:53:24-33: Implicit conversion of `str | Any | None` to `bool` is not allowed [implicit-bool]
- ERROR docs/utils/linkfix.py:54:52-61: Argument `None` is not assignable to parameter `data` with type `str` in function `pathlib.Path.write_text` [bad-argument-type]
+ ERROR docs/utils/linkfix.py:54:52-61: Argument `Unknown | None` is not assignable to parameter `data` with type `str` in function `pathlib.Path.write_text` [bad-argument-type] |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #5186
Flow merging now preserves the Never call’s termination information, so the example narrows x to str.
Test Plan
add test