-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Emit redundant-expr
warnings for if statements that are always true or always false.
#20068
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
base: master
Are you sure you want to change the base?
Conversation
Oh, 57 errors for Mypy itself, e.g. |
We already kind of have a distinction between things that are true at compile time and run time for unreachability reporting, maybe that has a nice way to do that here? Probably not though. (It's been too long for me to remember any special cases...) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: typeshed-stats (https://github.com/AlexWaygood/typeshed-stats)
+ src/typeshed_stats/gather.py:1226: error: If condition is always false [redundant-expr]
+ src/typeshed_stats/gather.py:1245: error: If condition is always false [redundant-expr]
aiohttp (https://github.com/aio-libs/aiohttp)
+ aiohttp/client_exceptions.py:323:4: error: If condition is always true [redundant-expr]
+ aiohttp/client_exceptions.py:323:4: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-redundant-expr for more info
+ aiohttp/helpers.py:127:12: error: If condition is always false [redundant-expr]
+ aiohttp/helpers.py:130:12: error: If condition is always false [redundant-expr]
+ aiohttp/helpers.py:170:12: error: If condition is always false [redundant-expr]
+ aiohttp/helpers.py:267:8: error: If condition is always false [redundant-expr]
+ aiohttp/helpers.py:877:14: error: If condition is always true [redundant-expr]
+ aiohttp/cookiejar.py:297:12: error: If condition is always false [redundant-expr]
+ aiohttp/cookiejar.py:485:15: error: While condition is always false [redundant-expr]
+ aiohttp/payload.py:132:14: error: If condition is always true [redundant-expr]
+ aiohttp/payload.py:352:14: error: If condition is always true [redundant-expr]
+ aiohttp/payload.py:962:12: error: If condition is always false [redundant-expr]
+ aiohttp/formdata.py:59:12: error: If condition is always false [redundant-expr]
+ aiohttp/formdata.py:69:16: error: If condition is always false [redundant-expr]
+ aiohttp/multipart.py:660:12: error: If condition is always false [redundant-expr]
+ aiohttp/connector.py:159:12: error: If condition is always true [redundant-expr]
+ aiohttp/connector.py:812:8: error: If condition is always false [redundant-expr]
+ aiohttp/connector.py:907:12: error: If condition is always false [redundant-expr]
+ aiohttp/connector.py:1165:12: error: If condition is always false [redundant-expr]
+ aiohttp/client_ws.py:243:12: error: If condition is always false [redundant-expr]
+ aiohttp/client_ws.py:250:12: error: If condition is always false [redundant-expr]
+ aiohttp/client_reqrep.py:169:4: error: If condition is always true [redundant-expr]
+ aiohttp/client_reqrep.py:275:12: error: If condition is always true [redundant-expr]
+ aiohttp/client_reqrep.py:1072:12: error: If condition is always false [redundant-expr]
+ aiohttp/client_reqrep.py:1227:12: error: If condition is always false [redundant-expr]
+ aiohttp/client_middleware_digest_auth.py:178:12: error: If condition is always false [redundant-expr]
+ aiohttp/client_middleware_digest_auth.py:181:12: error: If condition is always false [redundant-expr]
+ aiohttp/client.py:306:12: error: If condition is always false [redundant-expr]
+ aiohttp/client.py:462:12: error: If condition is always false [redundant-expr]
+ aiohttp/client.py:841:16: error: If condition is always false [redundant-expr]
+ aiohttp/client.py:948:16: error: If condition is always true [redundant-expr]
+ aiohttp/client.py:996:12: error: If condition is always false [redundant-expr]
+ aiohttp/web_response.py:267:14: error: If condition is always true [redundant-expr]
+ aiohttp/web_response.py:555:20: error: If condition is always false [redundant-expr]
+ aiohttp/web_fileresponse.py:328:16: error: If condition is always true [redundant-expr]
+ aiohttp/web_ws.py:415:12: error: If condition is always false [redundant-expr]
+ aiohttp/web_ws.py:424:12: error: If condition is always false [redundant-expr]
+ aiohttp/web_urldispatcher.py:778:12: error: If condition is always false [redundant-expr]
+ aiohttp/web_protocol.py:715:16: error: If condition is always false [redundant-expr]
+ aiohttp/web_app.py:283:12: error: If condition is always false [redundant-expr]
+ aiohttp/web_app.py:306:12: error: If condition is always false [redundant-expr]
+ aiohttp/web_runner.py:263:20: error: If condition is always true [redundant-expr]
+ aiohttp/web_runner.py:377:12: error: If condition is always false [redundant-expr]
+ aiohttp/worker.py:211:12: error: If condition is always false [redundant-expr]
+ aiohttp/test_utils.py:278:12: error: If condition is always false [redundant-expr]
+ aiohttp/pytest_plugin.py:416:14: error: If condition is always true [redundant-expr]
mypy (https://github.com/python/mypy)
+ mypyc/codegen/literals.py:66: error: If condition is always true [redundant-expr]
+ mypyc/codegen/literals.py:66: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-redundant-expr for more info
+ mypyc/codegen/literals.py:105: error: If condition is always true [redundant-expr]
+ mypy/nodes.py:4533: error: If condition is always true [redundant-expr]
+ mypy/nodes.py:4582: error: If condition is always true [redundant-expr]
+ mypy/nodes.py:4626: error: If condition is always true [redundant-expr]
+ mypy/nodes.py:4831: error: If condition is always true [redundant-expr]
+ mypy/traverser.py:126: error: If condition is always true [redundant-expr]
+ mypy/traverser.py:195: error: If condition is always true [redundant-expr]
+ mypy/traverser.py:201: error: If condition is always true [redundant-expr]
+ mypy/server/astmerge.py:448: error: If condition is always true [redundant-expr]
+ mypy/server/astmerge.py:460: error: If condition is always true [redundant-expr]
+ mypy/server/astmerge.py:477: error: If condition is always true [redundant-expr]
+ mypy/fixup.py:280: error: If condition is always true [redundant-expr]
+ mypy/fixup.py:282: error: If condition is always true [redundant-expr]
+ mypy/fixup.py:315: error: If condition is always true [redundant-expr]
+ mypy/fixup.py:322: error: If condition is always true [redundant-expr]
+ mypy/fixup.py:362: error: If condition is always true [redundant-expr]
+ mypy/errors.py:215: error: If condition is always true [redundant-expr]
+ mypyc/ir/pprint.py:217: error: If condition is always true [redundant-expr]
+ mypy/modulefinder.py:106: error: If condition is always true [redundant-expr]
+ mypy/fastparse.py:1525: error: If condition is always false [redundant-expr]
+ mypy/fastparse.py:1669: error: If condition is always true [redundant-expr]
+ mypy/fastparse.py:2077: error: If condition is always true [redundant-expr]
+ mypy/constraints.py:133: error: If condition is always false [redundant-expr]
+ mypy/constraints.py:133: note: Error code "redundant-expr" not covered by "type: ignore" comment
+ mypy/constraints.py:188: error: If condition is always true [redundant-expr]
+ mypy/messages.py:1254: error: If condition is always true [redundant-expr]
+ mypy/messages.py:2778: error: If condition is always false [redundant-expr]
+ mypyc/codegen/emitfunc.py:699: error: If condition is always true [redundant-expr]
+ mypyc/analysis/ircheck.py:307: error: If condition is always true [redundant-expr]
+ mypy/plugins/enums.py:228: error: If condition is always true [redundant-expr]
+ mypy/checkpattern.py:219: error: If condition is always true [redundant-expr]
+ mypy/server/astdiff.py:259: error: If condition is always true [redundant-expr]
+ mypy/checkstrformat.py:687: error: If condition is always true [redundant-expr]
+ mypy/checkstrformat.py:850: error: If condition is always true [redundant-expr]
+ mypy/plugins/dataclasses.py:140: error: If condition is always true [redundant-expr]
+ mypy/semanal.py:1003: error: If condition is always true [redundant-expr]
+ mypy/semanal.py:1403: error: If condition is always true [redundant-expr]
+ mypy/semanal.py:1494: error: If condition is always true [redundant-expr]
+ mypy/semanal.py:1504: error: If condition is always true [redundant-expr]
+ mypy/semanal.py:3872: error: If condition is always true [redundant-expr]
+ mypy/semanal.py:5817: error: If condition is always true [redundant-expr]
+ mypy/checkexpr.py:3545: error: If condition is always true [redundant-expr]
+ mypy/checker.py:894: error: If condition is always true [redundant-expr]
+ mypy/checker.py:2508: error: If condition is always true [redundant-expr]
+ mypy/checker.py:8654: error: If condition is always true [redundant-expr]
+ mypy/checker.py:8655: error: If condition is always true [redundant-expr]
+ mypy/checker.py:9029: error: If condition is always true [redundant-expr]
+ mypy/build.py:1087: error: If condition is always false [redundant-expr]
+ mypy/build.py:1318: error: If condition is always false [redundant-expr]
+ mypyc/irbuild/prepare.py:263: error: If condition is always true [redundant-expr]
+ mypy/stubtest.py:349: error: If condition is always false [redundant-expr]
+ mypy/stubtest.py:632: error: If condition is always false [redundant-expr]
+ mypy/stubtest.py:1920: error: If condition is always true [redundant-expr]
+ mypyc/irbuild/builder.py:621: error: If condition is always true [redundant-expr]
+ mypyc/irbuild/builder.py:719: error: If condition is always true [redundant-expr]
+ mypyc/irbuild/expression.py:919: error: If condition is always true [redundant-expr]
pyproject-metadata (https://github.com/pypa/pyproject-metadata)
+ pyproject_metadata/pyproject.py:77: error: If condition is always true [redundant-expr]
+ pyproject_metadata/pyproject.py:86: error: If condition is always false [redundant-expr]
+ pyproject_metadata/pyproject.py:100: error: If condition is always false [redundant-expr]
+ pyproject_metadata/pyproject.py:105: error: If condition is always false [redundant-expr]
+ pyproject_metadata/pyproject.py:168: error: If condition is always true [redundant-expr]
+ pyproject_metadata/pyproject.py:249: error: If condition is always true [redundant-expr]
+ pyproject_metadata/pyproject.py:333: error: If condition is always false [redundant-expr]
+ pyproject_metadata/pyproject.py:341: error: If condition is always false [redundant-expr]
+ pyproject_metadata/pyproject.py:351: error: If condition is always false [redundant-expr]
+ pyproject_metadata/pyproject.py:383: error: If condition is always false [redundant-expr]
+ pyproject_metadata/pyproject.py:396: error: If condition is always false [redundant-expr]
+ pyproject_metadata/pyproject.py:408: error: If condition is always false [redundant-expr]
+ pyproject_metadata/__init__.py:369: error: If condition is always false [redundant-expr]
CPython (cases_generator) (https://github.com/python/cpython)
+ Tools/cases_generator/cwriter.py:122: error: If condition is always true [redundant-expr]
rich (https://github.com/Textualize/rich)
+ rich/text.py:978: error: If condition is always false [redundant-expr]
+ rich/text.py:990: error: If condition is always true [redundant-expr]
+ rich/text.py:1241: error: If condition is always true [redundant-expr]
+ rich/rule.py:96: error: If condition is always true [redundant-expr]
+ rich/padding.py:71: error: If condition is always true [redundant-expr]
+ rich/highlighter.py:34: error: If condition is always true [redundant-expr]
+ rich/console.py:1791: error: If condition is always false [redundant-expr]
+ rich/box.py:144: error: If condition is always true [redundant-expr]
+ rich/align.py:178: error: If condition is always true [redundant-expr]
+ rich/file_proxy.py:29: error: If condition is always false [redundant-expr]
pyodide (https://github.com/pyodide/pyodide)
+ src/py/_pyodide/jsbind.py:113: error: If condition is always true [redundant-expr]
+ src/py/_pyodide/_importhook.py:71: error: If condition is always false [redundant-expr]
+ pyodide-build/pyodide_build/vendor/loky.py:166: error: If condition is always false [redundant-expr]
+ pyodide-build/pyodide_build/common.py:268: error: If condition is always true [redundant-expr]
+ pyodide-build/pyodide_build/recipe/skeleton.py:126: error: If condition is always true [redundant-expr]
+ src/py/pyodide/console.py:112: error: If condition is always false [redundant-expr]
+ src/py/pyodide/code.py:24: error: If condition is always false [redundant-expr]
+ src/py/pyodide/_run_js.py:13: error: If condition is always false [redundant-expr]
+ src/py/pyodide/http/_pyxhr.py:174: error: If condition is always true [redundant-expr]
CPython (peg_generator) (https://github.com/python/cpython)
+ Tools/peg_generator/pegen/c_generator.py:281: error: If condition is always true [redundant-expr]
packaging (https://github.com/pypa/packaging)
+ src/packaging/version.py:79: error: If condition is always false [redundant-expr]
+ src/packaging/version.py:85: error: If condition is always false [redundant-expr]
+ src/packaging/version.py:97: error: If condition is always false [redundant-expr]
+ src/packaging/version.py:103: error: If condition is always false [redundant-expr]
+ src/packaging/_manylinux.py:142: error: If condition is always false [redundant-expr]
+ src/packaging/specifiers.py:785: error: If condition is always false [redundant-expr]
+ src/packaging/markers.py:344: error: If condition is always false [redundant-expr]
+ src/packaging/metadata.py:386: error: If condition is always false [redundant-expr]
poetry (https://github.com/python-poetry/poetry)
+ src/poetry/utils/_compat.py:39: error: If condition is always false [redundant-expr]
+ src/poetry/pyproject/toml.py:48: error: If condition is always false [redundant-expr]
+ src/poetry/utils/authenticator.py:164: error: If condition is always true [redundant-expr]
+ src/poetry/utils/authenticator.py:263: error: If condition is always true [redundant-expr]
+ src/poetry/config/source.py:23: error: If condition is always false [redundant-expr]
+ src/poetry/utils/env/env_manager.py:196: error: If condition is always false [redundant-expr]
+ src/poetry/utils/env/env_manager.py:377: error: If condition is always false [redundant-expr]
+ src/poetry/installation/executor.py:819: error: If condition is always false [redundant-expr]
+ src/poetry/plugins/plugin_manager.py:85: error: If condition is always false [redundant-expr]
+ src/poetry/console/commands/remove.py:70: error: If condition is always false [redundant-expr]
+ tests/console/commands/test_install.py:155: error: If condition is always false [redundant-expr]
+ tests/console/commands/test_build.py:184: error: If condition is always false [redundant-expr]
+ src/poetry/console/commands/add.py:329: error: If condition is always true [redundant-expr]
archinstall (https://github.com/archlinux/archinstall)
+ archinstall/tui/curses_menu.py:908: error: If condition is always false [redundant-expr]
+ archinstall/lib/output.py:45: error: If condition is always true [redundant-expr]
+ archinstall/lib/general.py:345: error: If condition is always true [redundant-expr]
+ archinstall/lib/models/authentication.py:47: error: If condition is always false [redundant-expr]
+ archinstall/lib/models/mirrors.py:100: error: If condition is always true [redundant-expr]
+ archinstall/lib/models/device.py:321: error: If condition is always false [redundant-expr]
+ archinstall/lib/models/device.py:1178: error: If condition is always false [redundant-expr]
+ archinstall/lib/luks.py:46: error: If condition is always false [redundant-expr]
+ archinstall/lib/installer.py:840: error: If condition is always true [redundant-expr]
+ archinstall/lib/installer.py:946: error: If condition is always true [redundant-expr]
+ archinstall/lib/authentication/authentication_menu.py:120: error: If condition is always true [redundant-expr]
+ archinstall/lib/profile/profile_menu.py:142: error: If condition is always true [redundant-expr]
yarl (https://github.com/aio-libs/yarl)
+ yarl/_quoting_py.py:43:12: error: If condition is always false [redundant-expr]
+ yarl/_quoting_py.py:43:12: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-redundant-expr for more info
+ yarl/_quoting_py.py:144:12: error: If condition is always false [redundant-expr]
+ yarl/_quoting_py.py:174:28: error: If condition is always false [redundant-expr]
+ yarl/_quoting_py.py:179:28: error: If condition is always false [redundant-expr]
+ yarl/_url.py:408:12: error: If condition is always false [redundant-expr]
+ yarl/_url.py:549:12: error: If condition is always false [redundant-expr]
+ yarl/_url.py:1059:12: error: If condition is always false [redundant-expr]
+ yarl/_url.py:1082:14: error: If condition is always true [redundant-expr]
+ yarl/_url.py:1104:14: error: If condition is always true [redundant-expr]
+ yarl/_url.py:1125:12: error: If condition is always false [redundant-expr]
+ yarl/_url.py:1319:14: error: If condition is always false [redundant-expr]
+ yarl/_url.py:1344:12: error: If condition is always false [redundant-expr]
+ yarl/_url.py:1380:12: error: If condition is always false [redundant-expr]
build (https://github.com/pypa/build)
+ src/build/__main__.py:187: error: If condition is always true [redundant-expr]
xarray (https://github.com/pydata/xarray)
+ xarray/backends/lru_cache.py: note: In member "__init__" of class "LRUCache":
+ xarray/backends/lru_cache.py:44: error: If condition is always false [redundant-expr]
+ xarray/compat/npcompat.py: note: In function "isdtype":
+ xarray/compat/npcompat.py:72: error: If condition is always false [redundant-expr]
+ xarray/namedarray/utils.py: note: In function "drop_missing_dims":
+ xarray/namedarray/utils.py:144: error: If condition is always true [redundant-expr]
+ xarray/core/utils.py: note: In function "equivalent":
+ xarray/core/utils.py:266: error: If condition is always false [redundant-expr]
+ xarray/core/utils.py: note: In function "drop_dims_from_indexers":
+ xarray/core/utils.py:925: error: If condition is always true [redundant-expr]
+ xarray/namedarray/pycompat.py: note: In member "__init__" of class "DuckArrayModule":
+ xarray/namedarray/pycompat.py:53: error: If condition is always true [redundant-expr]
+ xarray/core/treenode.py: note: In member "_set_parent" of class "TreeNode":
+ xarray/core/treenode.py:101: error: If condition is always false [redundant-expr]
+ xarray/core/treenode.py: note: In function "_validate_name":
+ xarray/core/treenode.py:668: error: If condition is always false [redundant-expr]
+ xarray/backends/locks.py: note: In function "combine_locks":
+ xarray/backends/locks.py:267: error: If condition is always true [redundant-expr]
+ xarray/namedarray/parallelcompat.py: note: In function "guess_chunkmanager":
+ xarray/namedarray/parallelcompat.py:133: error: If condition is always true [redundant-expr]
+ xarray/core/indexing.py: note: In function "group_indexers_by_index":
+ xarray/core/indexing.py:147: error: If condition is always true [redundant-expr]
+ xarray/core/indexing.py: note: In function "map_index_queries":
+ xarray/core/indexing.py:197: error: If condition is always false [redundant-expr]
+ xarray/core/indexing.py: note: In member "__init__" of class "BasicIndexer":
+ xarray/core/indexing.py:461: error: If condition is always false [redundant-expr]
+ xarray/core/indexing.py:468: error: If condition is always true [redundant-expr]
+ xarray/core/indexing.py: note: In member "__init__" of class "OuterIndexer":
+ xarray/core/indexing.py:494: error: If condition is always false [redundant-expr]
+ xarray/core/indexing.py: note: In member "__init__" of class "VectorizedIndexer":
+ xarray/core/indexing.py:536: error: If condition is always false [redundant-expr]
+ xarray/core/indexing.py: note: In function "_decompose_outer_indexer":
+ xarray/core/indexing.py:1398: error: If condition is always false [redundant-expr]
+ xarray/core/indexing.py: note: At top level:
+ xarray/namedarray/core.py: note: In function "from_array":
+ xarray/namedarray/core.py:190: error: If condition is always false [redundant-expr]
+ xarray/namedarray/core.py: note: At top level:
+ xarray/core/indexes.py: note: In member "from_variables" of class "PandasIndex":
+ xarray/core/indexes.py:722: error: If condition is always false [redundant-expr]
+ xarray/core/indexes.py: note: In member "to_pandas_indexes" of class "Indexes":
+ xarray/core/indexes.py:1853: error: If condition is always false [redundant-expr]
+ xarray/core/indexes.py:1853: error: If condition is always true [redundant-expr]
+ xarray/core/indexes.py:1855: error: If condition is always true [redundant-expr]
+ xarray/core/indexes.py: note: In member "copy_indexes" of class "Indexes":
+ xarray/core/indexes.py:1881: error: If condition is always false [redundant-expr]
+ xarray/core/indexes.py:1881: error: If condition is always true [redundant-expr]
+ xarray/core/formatting.py: note: In function "summarize_variable":
+ xarray/core/formatting.py:340: error: If condition is always false [redundant-expr]
+ xarray/core/common.py: note: In member "_resample" of class "DataWithCoords":
+ xarray/core/common.py:1112: error: If condition is always true [redundant-expr]
+ xarray/core/common.py: note: In function "full_like":
+ xarray/core/common.py:1741: error: If condition is always true [redundant-expr]
+ xarray/plot/facetgrid.py: note: In member "set_axis_labels" of class "FacetGrid":
+ xarray/plot/facetgrid.py:852: error: If condition is always false [redundant-expr]
+ xarray/plot/facetgrid.py: note: At top level:
+ xarray/plot/facetgrid.py: note: In function "_easy_facetgrid":
+ xarray/plot/facetgrid.py:1082: error: If condition is always true [redundant-expr]
+ xarray/core/variable.py: note: In function "_maybe_wrap_data":
+ xarray/core/variable.py:202: error: If condition is always true [redundant-expr]
+ xarray/core/variable.py: note: In function "as_compatible_data":
+ xarray/core/variable.py:290: error: If condition is always true [redundant-expr]
+ xarray/core/variable.py: note: In member "_pad_options_dim_to_index" of class "Variable":
+ xarray/core/variable.py:1225: error: If condition is always false [redundant-expr]
+ xarray/core/variable.py: note: At top level:
+ xarray/structure/merge.py: note: In function "coerce_pandas_values":
+ xarray/structure/merge.py:530: error: If condition is always false [redundant-expr]
+ xarray/computation/computation.py: note: In function "cov":
+ xarray/computation/computation.py:147: error: If condition is always false [redundant-expr]
+ xarray/computation/computation.py: note: In function "corr":
+ xarray/computation/computation.py:250: error: If condition is always false [redundant-expr]
+ xarray/core/coordinates.py: note: In member "equals" of class "Coordinates":
+ xarray/core/coordinates.py:477: error: If condition is always false [redundant-expr]
+ xarray/core/coordinates.py: note: In member "identical" of class "Coordinates":
+ xarray/core/coordinates.py:488: error: If condition is always false [redundant-expr]
+ xarray/computation/apply_ufunc.py: note: In function "apply_dict_of_variables_vfunc":
+ xarray/computation/apply_ufunc.py:455: error: If condition is always true [redundant-expr]
+ xarray/coding/cftimeindex.py: note: In member "shift" of class "CFTimeIndex":
+ xarray/coding/cftimeindex.py:508: error: If condition is always true [redundant-expr]
+ xarray/conventions.py: note: In function "ensure_not_multiindex":
+ xarray/conventions.py:56: error: If condition is always false [redundant-expr]
+ xarray/conventions.py: note: In function "decode_cf":
+ xarray/conventions.py:578: error: If condition is always true [redundant-expr]
+ xarray/coding/cftime_offsets.py: note: In member "__init__" of class "BaseCFTimeOffset":
+ xarray/coding/cftime_offsets.py:114: error: If condition is always false [redundant-expr]
+ xarray/coding/cftime_offsets.py: note: In member "__mul__" of class "BaseCFTimeOffset":
+ xarray/coding/cftime_offsets.py:149: error: If condition is always false [redundant-expr]
+ xarray/coding/cftime_offsets.py: note: In member "__mul__" of class "Tick":
+ xarray/coding/cftime_offsets.py:218: error: If condition is always false [redundant-expr]
+ xarray/coding/cftime_offsets.py: note: In function "_get_day_of_month":
+ xarray/coding/cftime_offsets.py:256: error: If condition is always true [redundant-expr]
+ xarray/coding/cftime_offsets.py: note: In function "_shift_month":
+ xarray/coding/cftime_offsets.py:311: error: If condition is always true [redundant-expr]
+ xarray/coding/cftime_offsets.py: note: In function "_validate_month":
+ xarray/coding/cftime_offsets.py:363: error: If condition is always false [redundant-expr]
+ xarray/coding/cftime_offsets.py: note: In function "_cftime_range":
+ xarray/coding/cftime_offsets.py:1206: error: If condition is always false [redundant-expr]
+ xarray/coding/cftime_offsets.py: note: In function "_legacy_to_new_freq":
+ xarray/coding/cftime_offsets.py:1510: error: If condition is always true [redundant-expr]
+ xarray/plot/dataarray_plot.py: note: In function "line":
+ xarray/plot/dataarray_plot.py:521: error: If condition is always true [redundant-expr]
+ xarray/plot/dataarray_plot.py:524: error: If condition is always true [redundant-expr]
+ xarray/plot/dataarray_plot.py: note: At top level:
+ xarray/plot/dataarray_plot.py: note: In function "_add_labels":
+ xarray/plot/dataarray_plot.py:1110: error: If condition is always true [redundant-expr]
+ xarray/plot/dataarray_plot.py: note: In function "_plot2d":
+ xarray/plot/dataarray_plot.py:1606: error: If condition is always false [redundant-expr]
+ xarray/core/resample_cftime.py: note: In function "_get_time_bins":
+ xarray/core/resample_cftime.py:221: error: If condition is always false [redundant-expr]
+ xarray/core/groupby.py: note: In function "_consolidate_slices":
+ xarray/core/groupby.py:143: error: If condition is always false [redundant-expr]
+ xarray/core/groupby.py: note: In member "__post_init__" of class "ResolvedGrouper":
+ xarray/core/groupby.py:333: error: If condition is always false [redundant-expr]
+ xarray/core/groupby.py: note: In function "_parse_group_and_groupers":
+ xarray/core/groupby.py:403: error: If condition is always false [redundant-expr]
+ xarray/core/groupby.py:408: error: If condition is always false [redundant-expr]
+ xarray/core/groupby.py: note: In function "_validate_groupby_squeeze":
+ xarray/core/groupby.py:453: error: If condition is always false [redundant-expr]
+ xarray/core/groupby.py: note: At top level:
+ xarray/core/dataset.py: note: In member "head" of class "Dataset":
+ xarray/core/dataset.py:3110: error: If condition is always false [redundant-expr]
+ xarray/core/dataset.py: note: In member "tail" of class "Dataset":
+ xarray/core/dataset.py:3198: error: If condition is always false [redundant-expr]
+ xarray/core/dataset.py: note: In member "thin" of class "Dataset":
+ xarray/core/dataset.py:3284: error: If condition is always false [redundant-expr]
+ xarray/core/dataset.py: note: In member "expand_dims" of class "Dataset":
+ xarray/core/dataset.py:4576: error: If condition is always true [redundant-expr]
+ xarray/core/dataset.py: note: In member "set_xindex" of class "Dataset":
+ xarray/core/dataset.py:4986: error: If condition is always false [redundant-expr]
+ xarray/core/dataset.py: note: In member "transpose" of class "Dataset":
+ xarray/core/dataset.py:6237: error: If condition is always false [redundant-expr]
+ xarray/core/dataset.py: note: In member "dropna" of class "Dataset":
+ xarray/core/dataset.py:6378: error: If condition is always true [redundant-expr]
+ xarray/core/dataset.py: note: In member "diff" of class "Dataset":
+ xarray/core/dataset.py:7838: error: If condition is always true [redundant-expr]
+ xarray/core/dataset.py: note: In member "sortby" of class "Dataset":
+ xarray/core/dataset.py:8102: error: If condition is always true [redundant-expr]
+ xarray/core/dataarray.py: note: In member "_inplace_binary_op" of class "DataArray":
+ xarray/core/dataarray.py:4910: error: If condition is always false [redundant-expr]
+ xarray/core/dataarray.py: note: In member "dot" of class "DataArray":
+ xarray/core/dataarray.py:5184: error: If condition is always false [redundant-expr]
+ xarray/core/dataarray.py:5184: error: If condition is always true [redundant-expr]
+ xarray/core/dataarray.py:5188: error: If condition is always false [redundant-expr]
+ xarray/groupers.py: note: In member "_init_properties" of class "TimeResampler":
+ xarray/groupers.py:524: error: If condition is always false [redundant-expr]
+ xarray/indexes/nd_point_index.py: note: In member "from_variables" of class "NDPointIndex":
+ xarray/indexes/nd_point_index.py:270: error: If condition is always false [redundant-expr]
+ xarray/core/parallel.py: note: In function "check_result_variables":
+ xarray/core/parallel.py:50: error: If condition is always true [redundant-expr]
+ xarray/core/parallel.py: note: In function "dataset_to_dataarray":
+ xarray/core/parallel.py:69: error: If condition is always false [redundant-expr]
+ xarray/core/parallel.py: note: At top level:
+ xarray/core/parallel.py: note: In function "infer_template":
+ xarray/core/parallel.py:133: error: If condition is always false [redundant-expr]
+ xarray/core/parallel.py: note: At top level:
+ xarray/core/parallel.py: note: In function "map_blocks":
+ xarray/core/parallel.py:395: error: If condition is always false [redundant-expr]
+ xarray/core/parallel.py:399: error: If condition is always false [redundant-expr]
+ xarray/core/parallel.py:403: error: If condition is always false [redundant-expr]
+ xarray/core/parallel.py: note: At top level:
+ xarray/core/parallel.py: note: In function "map_blocks":
+ xarray/core/parallel.py:522: error: If condition is always true [redundant-expr]
+ xarray/core/datatree.py: note: In function "_to_new_dataset":
+ xarray/core/datatree.py:140: error: If condition is always true [redundant-expr]
+ xarray/core/datatree.py: note: In member "__getitem__" of class "DataTree":
+ xarray/core/datatree.py:967: error: If condition is always true [redundant-expr]
+ xarray/core/datatree.py: note: In member "__setitem__" of class "DataTree":
+ xarray/core/datatree.py:1015: error: If condition is always true [redundant-expr]
+ xarray/core/datatree.py: note: In function "update":
+ xarray/core/datatree.py:1079: error: If condition is always true [redundant-expr]
+ xarray/testing/assertions.py: note: In function "assert_isomorphic":
+ xarray/testing/assertions.py:81: error: If condition is always true [redundant-expr]
+ xarray/testing/assertions.py: note: In function "_assert_dataarray_invariants":
+ xarray/testing/assertions.py:431: error: If condition is always true [redundant-expr]
+ xarray/testing/assertions.py: note: In function "_assert_dataset_invariants":
+ xarray/testing/assertions.py:466: error: If condition is always true [redundant-expr]
+ xarray/testing/assertions.py: note: In function "_assert_internal_invariants":
+ xarray/testing/assertions.py:490: error: If condition is always true [redundant-expr]
+ xarray/backends/common.py: note: In function "ensure_dtype_not_object":
+ xarray/backends/common.py:682: error: If condition is always false [redundant-expr]
+ xarray/backends/common.py:682: error: If condition is always true [redundant-expr]
+ xarray/backends/plugins.py: note: In function "get_backend":
+ xarray/backends/plugins.py:227: error: If condition is always true [redundant-expr]
+ xarray/backends/api.py: note: In function "open_mfdataset":
+ xarray/backends/api.py:1676: error: If condition is always true [redundant-expr]
+ xarray/computation/weighted.py: note: In member "__init__" of class "Weighted":
+ xarray/computation/weighted.py:170: error: If condition is always false [redundant-expr]
+ xarray/computation/weighted.py: note: At top level:
+ xarray/computation/weighted.py: note: In function "_weighted_quantile":
+ xarray/computation/weighted.py:342: error: If condition is always true [redundant-expr]
+ xarray/computation/rolling.py: note: In member "_numbagg_reduce" of class "DataArrayRolling":
+ xarray/computation/rolling.py:627: error: If condition is always false [redundant-expr]
+ xarray/computation/rolling.py: note: In member "construct" of class "Coarsen":
+ xarray/computation/rolling.py:1191: error: If condition is always true [redundant-expr]
+ xarray/computation/rolling.py:1191: error: If condition is always false [redundant-expr]
+ xarray/computation/rolling.py:1215: error: If condition is always true [redundant-expr]
+ xarray/computation/rolling.py:1215: error: If condition is always false [redundant-expr]
+ xarray/tests/arrays.py: note: In function "broadcast_to":
+ xarray/tests/arrays.py:122: error: If condition is always false [redundant-expr]
+ xarray/tests/arrays.py: note: In function "full_like":
+ xarray/tests/arrays.py:136: error: If condition is always false [redundant-expr]
+ xarray/tests/test_namedarray.py: note: In function "check_duck_array_typevar":
+ xarray/tests/test_namedarray.py:96: error: If condition is always true [redundant-expr]
+ xarray/tests/test_indexing.py: note: In member "test_group_indexers_by_index" of class "TestIndexers":
+ xarray/tests/test_indexing.py:104: error: If condition is always false [redundant-expr]
+ xarray/tests/test_indexing.py: note: At top level:
+ xarray/tests/test_backends.py: note: In member "check_dtypes_roundtripped" of class "DatasetIOBase":
+ xarray/tests/test_backends.py:520: error: If condition is always false [redundant-expr]
+ xarray/tests/test_backends.py: note: At top level:
+ xarray/testing/strategies.py: note: In function "variables":
+ xarray/testing/strategies.py:342: error: If condition is always false [redundant-expr]
... (truncated 4 lines) ...
scikit-build-core (https://github.com/scikit-build/scikit-build-core)
+ src/scikit_build_core/settings/skbuild_overrides.py:219: error: If condition is always false [redundant-expr]
+ src/scikit_build_core/_vendor/pyproject_metadata/pyproject.py:77: error: If condition is always true [redundant-expr]
+ src/scikit_build_core/_vendor/pyproject_metadata/pyproject.py:86: error: If condition is always false [redundant-expr]
+ src/scikit_build_core/_vendor/pyproject_metadata/pyproject.py:100: error: If condition is always false [redundant-expr]
+ src/scikit_build_core/_vendor/pyproject_metadata/pyproject.py:105: error: If condition is always false [redundant-expr]
+ src/scikit_build_core/_vendor/pyproject_metadata/pyproject.py:168: error: If condition is always true [redundant-expr]
+ src/scikit_build_core/_vendor/pyproject_metadata/pyproject.py:249: error: If condition is always true [redundant-expr]
+ src/scikit_build_core/_vendor/pyproject_metadata/pyproject.py:333: error: If condition is always false [redundant-expr]
+ src/scikit_build_core/_vendor/pyproject_metadata/pyproject.py:341: error: If condition is always false [redundant-expr]
+ src/scikit_build_core/_vendor/pyproject_metadata/pyproject.py:351: error: If condition is always false [redundant-expr]
+ src/scikit_build_core/_vendor/pyproject_metadata/pyproject.py:383: error: If condition is always false [redundant-expr]
+ src/scikit_build_core/_vendor/pyproject_metadata/pyproject.py:396: error: If condition is always false [redundant-expr]
+ src/scikit_build_core/_vendor/pyproject_metadata/pyproject.py:408: error: If condition is always false [redundant-expr]
+ src/scikit_build_core/_vendor/pyproject_metadata/__init__.py:369: error: If condition is always false [redundant-expr]
+ src/scikit_build_core/setuptools/build_cmake.py:250: error: If condition is always false [redundant-expr]
+ src/scikit_build_core/hatch/plugin.py:73: error: If condition is always false [redundant-expr]
+ src/scikit_build_core/build/wheel.py:398: error: If condition is always true [redundant-expr]
+ src/scikit_build_core/build/__main__.py:45: error: If condition is always true [redundant-expr]
boostedblob (https://github.com/hauntsaninja/boostedblob)
+ boostedblob/boost.py:312: error: If condition is always false [redundant-expr]
+ boostedblob/boost.py:578: error: If condition is always true [redundant-expr]
+ boostedblob/boost.py:590: error: If condition is always true [redundant-expr]
+ boostedblob/boost.py:603: error: If condition is always true [redundant-expr]
+ boostedblob/path.py:88: error: If condition is always false [redundant-expr]
+ boostedblob/path.py:168: error: If condition is always false [redundant-expr]
+ boostedblob/path.py:237: error: If condition is always false [redundant-expr]
nox (https://github.com/wntrblm/nox)
+ nox/sessions.py:613: error: If condition is always false [redundant-expr]
|
A few looks into the primer results (from bottom to top; without obvious repetitions): noxMypy issues (in this case already under discussion in #11764). x: str | None,
if callable(x): # error: If condition is always false
... # type: ignore[unreachable] boostedblobAdditional runtime type checking. def f(x: str | int) -> None:
if not isinstance(x, str | int): # error: If condition is always false
raise ValueError
def g(x: str | int) -> None:
if isinstance(x, str):
return
if isinstance(x, int): # error: If condition is always true
return
raise AssertionError scikit-build-coreReally redundant code (or at least one that needs explanations): def f(env: dict[str, str] | None):
if env:
for key, value in env.items():
if isinstance(value, bool): # error: If condition is always false
... import dataclasses
@dataclasses.dataclass
class Settings1:
cmake: bool = False
@dataclasses.dataclass
class Settings2:
cmake: bool = False
def f(s1: Settings1, s2: Settings2) -> None:
if not s1.cmake or s2.cmake:
...
if s2.cmake: # error: If condition is always false
... Based on these few examples, this PR seems correct. However, it somehow collides with exhaustiveness checking. |
Fixes #19728
And thereby implements the two XXX comments of
TypeChecker.visit_if_stmt
.The only surprise I encountered is that we must take care of while statements here, too, because while statements are transformed to if statements during type checking. It seems right to me to only emit warnings for
while False
but not forwhile True
.@A5rocks: Are you aware of other, uncovered special cases?