Skip to content

Suggest narrowing for None in union attribute errors#20888

Open
dhruvildarji wants to merge 2 commits intopython:masterfrom
dhruvildarji:fix/union-none-narrowing-hint
Open

Suggest narrowing for None in union attribute errors#20888
dhruvildarji wants to merge 2 commits intopython:masterfrom
dhruvildarji:fix/union-none-narrowing-hint

Conversation

@dhruvildarji
Copy link

Summary

When accessing an attribute on a union type that includes None, mypy now emits a note suggesting the user narrow the type with an if x is not None guard:

error: Item "None" of "str | None" has no attribute "startswith"
note: You can use "if s is not None" to guard against a None value

This is especially helpful for beginners who may not know about type narrowing. The note is only shown when:

  • The offending union item is None (not for arbitrary Union[A, B])
  • The variable name can be extracted from the AST context (simple names like x, or member access like self.a)
  • For complex expressions like items[0].attr, the note is skipped to avoid unhelpful suggestions

Fixes #17036

dhruvildarji and others added 2 commits February 23, 2026 22:25
When accessing an attribute on a union type that includes None,
mypy now suggests using an "if x is not None" guard. This helps
users, especially beginners, understand how to resolve the common
pattern of accessing attributes on Optional types.

Fixes python#17036
@github-actions
Copy link
Contributor

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

prefect (https://github.com/PrefectHQ/prefect)
+ src/prefect/_internal/analytics/client.py:120: note: You can use "if _amplitude_client is not None" to guard against a None value
+ src/prefect/_internal/schemas/validators.py:237: note: You can use "if anchor_date.tzinfo is not None" to guard against a None value
+ src/prefect/_internal/compatibility/deprecated.py:106: note: You can use "if end_date is not None" to guard against a None value
+ src/prefect/futures.py:327: note: You can use "if task_run.state is not None" to guard against a None value
+ src/prefect/task_runners.py:724: note: You can use "if self._executor is not None" to guard against a None value
+ src/prefect/deployments/runner.py:875: note: You can use "if value is not None" to guard against a None value
+ src/prefect/server/services/task_run_recorder.py:67: note: You can use "if task_run.state is not None" to guard against a None value
+ src/prefect/flow_engine.py:513: note: You can use "if self.flow_run is not None" to guard against a None value
+ src/prefect/flow_engine.py:1117: note: You can use "if self.flow_run is not None" to guard against a None value
+ src/prefect/server/orchestration/global_policy.py:462: note: You can use "if context.proposed_state is not None" to guard against a None value
+ src/prefect/server/orchestration/global_policy.py:466: note: You can use "if context.proposed_state is not None" to guard against a None value
+ src/prefect/server/orchestration/global_policy.py:467: note: You can use "if context.proposed_state is not None" to guard against a None value
+ src/prefect/task_engine.py:944: note: You can use "if self.task_run is not None" to guard against a None value
+ src/prefect/task_engine.py:946: note: You can use "if self.task_run is not None" to guard against a None value
+ src/prefect/task_engine.py:1138: note: You can use "if self.task_run is not None" to guard against a None value
+ src/prefect/task_engine.py:1144: note: You can use "if self.task_run is not None" to guard against a None value
+ src/prefect/task_engine.py:1144: note: You can use "if flow_run is not None" to guard against a None value
+ src/prefect/task_engine.py:1572: note: You can use "if self.task_run is not None" to guard against a None value
+ src/prefect/task_engine.py:1574: note: You can use "if self.task_run is not None" to guard against a None value
+ src/prefect/server/api/deployments.py:86: note: You can use "if updated_by is not None" to guard against a None value
+ src/prefect/runtime/flow_run.py:140: note: You can use "if flow_run_ctx.flow_run is not None" to guard against a None value
+ src/prefect/runtime/flow_run.py:160: note: You can use "if flow_run_ctx.flow_run is not None" to guard against a None value
+ src/prefect/runtime/flow_run.py:175: note: You can use "if flow_run_ctx.flow_run is not None" to guard against a None value
+ src/prefect/runtime/flow_run.py:190: note: You can use "if flow_run_ctx.flow_run is not None" to guard against a None value
+ src/prefect/runtime/flow_run.py:205: note: You can use "if flow_run_ctx.flow is not None" to guard against a None value
+ src/prefect/runtime/flow_run.py:220: note: You can use "if flow_run_ctx.flow is not None" to guard against a None value
+ src/prefect/runtime/flow_run.py:235: note: You can use "if flow_run_ctx.flow_run is not None" to guard against a None value
+ src/prefect/runtime/flow_run.py:258: note: You can use "if flow_run_ctx.flow_run is not None" to guard against a None value
+ src/prefect/runtime/flow_run.py:335: note: You can use "if flow_run_ctx.flow_run is not None" to guard against a None value
+ src/prefect/runtime/deployment.py:171: note: You can use "if flow_run_ctx.flow_run is not None" to guard against a None value
+ src/prefect/flow_runs.py:260: note: You can use "if context.flow_run is not None" to guard against a None value
+ src/prefect/flow_runs.py:296: note: You can use "if context.flow_run is not None" to guard against a None value
+ src/prefect/flow_runs.py:414: note: You can use "if context.flow_run is not None" to guard against a None value
+ src/prefect/flow_runs.py:450: note: You can use "if context.flow_run is not None" to guard against a None value
+ src/prefect/flow_runs.py:461: note: You can use "if context.flow_run is not None" to guard against a None value
+ src/prefect/deployments/flow_runs.py:185: note: You can use "if flow_run_ctx.flow_run is not None" to guard against a None value
+ src/prefect/deployments/flow_runs.py:187: note: You can use "if task_run_ctx is not None" to guard against a None value
+ src/prefect/deployments/flow_runs.py:192: note: You can use "if task_run_ctx is not None" to guard against a None value
+ src/prefect/deployments/flow_runs.py:382: note: You can use "if flow_run_ctx.flow_run is not None" to guard against a None value
+ src/prefect/deployments/flow_runs.py:384: note: You can use "if task_run_ctx is not None" to guard against a None value
+ src/prefect/deployments/flow_runs.py:389: note: You can use "if task_run_ctx is not None" to guard against a None value
+ src/prefect/deployments/base.py:71: note: You can use "if contents is not None" to guard against a None value
+ src/prefect/deployments/base.py:83: note: You can use "if contents is not None" to guard against a None value
+ src/prefect/deployments/base.py:95: note: You can use "if contents is not None" to guard against a None value
+ src/prefect/deployments/base.py:108: note: You can use "if contents is not None" to guard against a None value
+ src/prefect/cli/flow_run.py:289: note: You can use "if flow_run.state is not None" to guard against a None value
+ src/prefect/cli/flow_run.py:290: note: You can use "if flow_run.state is not None" to guard against a None value
+ src/prefect/cli/flow_run.py:291: note: You can use "if flow_run.state is not None" to guard against a None value
+ src/prefect/cli/flow_run.py:297: note: You can use "if flow_run.state is not None" to guard against a None value
+ src/prefect/cli/cloud/__init__.py:371: note: You can use "if workspace is not None" to guard against a None value
+ src/prefect/cli/cloud/__init__.py:373: note: You can use "if workspace is not None" to guard against a None value
+ src/prefect/infrastructure/provisioners/container_instance.py:732: note: You can use "if credentials_block_schema is not None" to guard against a None value
+ src/prefect/infrastructure/provisioners/cloud_run.py:239: note: You can use "if credentials_block_schema is not None" to guard against a None value
+ src/prefect/cli/_server_utils.py:219: note: You can use "if settings.server.database.connection_url is not None" to guard against a None value
+ src/prefect/cli/work_pool.py:258: note: You can use "if work_pool.status is not None" to guard against a None value
+ src/prefect/cli/_cyclopts/work_pool.py:264: note: You can use "if work_pool.status is not None" to guard against a None value
+ src/prefect/cli/_cyclopts/flow_run.py:264: note: You can use "if flow_run.state is not None" to guard against a None value
+ src/prefect/cli/_cyclopts/flow_run.py:265: note: You can use "if flow_run.state is not None" to guard against a None value
+ src/prefect/cli/_cyclopts/flow_run.py:266: note: You can use "if flow_run.state is not None" to guard against a None value
+ src/prefect/cli/_cyclopts/flow_run.py:272: note: You can use "if flow_run.state is not None" to guard against a None value
+ src/prefect/cli/_cyclopts/cloud.py:442: note: You can use "if workspace is not None" to guard against a None value
+ src/prefect/cli/_cyclopts/cloud.py:444: note: You can use "if workspace is not None" to guard against a None value

colour (https://github.com/colour-science/colour)
+ colour/utilities/network.py:1459: note: You can use "if port_source is not None" to guard against a None value
+ colour/utilities/network.py:1507: note: You can use "if port_source is not None" to guard against a None value
+ colour/io/tabular.py:164: note: You can use "if data.dtype is not None" to guard against a None value

Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ tanjun/dependencies/limiters.py:814: note: You can use "if resource is not None" to guard against a None value

schemathesis (https://github.com/schemathesis/schemathesis)
+ src/schemathesis/generation/hypothesis/builder.py:154: note: You can use "if default is not None" to guard against a None value

operator (https://github.com/canonical/operator)
+ ops/lib/__init__.py:272: note: You can use "if self.spec.loader is not None" to guard against a None value

cki-lib (https://gitlab.com/cki-project/cki-lib)
+ cki_lib/kcidb/checks.py:81: note: You can use "if dw_all is not None" to guard against a None value
+ tests/test_gitlab.py:251: note: You can use "if gl_setup'.gl_group is not None" to guard against a None value
+ tests/test_gitlab.py:256: note: You can use "if gl_setup''.gl_project is not None" to guard against a None value
+ tests/test_gitlab.py:261: note: You can use "if gl_setup'''.gl_project is not None" to guard against a None value
+ tests/test_cronjob.py:83: note: You can use "if runner is not None" to guard against a None value
+ tests/test_cronjob.py:109: note: You can use "if runner is not None" to guard against a None value
+ tests/test_cronjob.py:117: note: You can use "if runner is not None" to guard against a None value
+ tests/test_cronjob.py:127: note: You can use "if runner is not None" to guard against a None value

core (https://github.com/home-assistant/core)
+ homeassistant/components/minecraft_server/api.py:95: note: You can use "if self._server is not None" to guard against a None value

pytest (https://github.com/pytest-dev/pytest)
+ testing/test_collection.py:87: note: You can use "if modcol is not None" to guard against a None value
+ testing/test_collection.py:88: note: You can use "if modcol is not None" to guard against a None value
+ testing/test_collection.py:89: note: You can use "if modcol is not None" to guard against a None value
+ testing/_py/test_local.py:851: note: You can use "if x is not None" to guard against a None value
+ testing/_py/test_local.py:854: note: You can use "if x is not None" to guard against a None value
+ testing/_py/test_local.py:905: note: You can use "if x is not None" to guard against a None value
+ testing/_py/test_local.py:907: note: You can use "if y is not None" to guard against a None value
+ testing/_py/test_local.py:916: note: You can use "if x is not None" to guard against a None value
+ testing/_py/test_local.py:917: note: You can use "if x is not None" to guard against a None value
+ testing/_py/test_local.py:922: note: You can use "if x is not None" to guard against a None value
+ testing/_py/test_local.py:933: note: You can use "if x is not None" to guard against a None value
+ testing/_py/test_local.py:1274: note: You can use "if cmd is not None" to guard against a None value
+ testing/_py/test_local.py:1276: note: You can use "if cmd is not None" to guard against a None value
+ testing/_py/test_local.py:1277: note: You can use "if x is not None" to guard against a None value

mitmproxy (https://github.com/mitmproxy/mitmproxy)
+ web/gen/web_columns.py:22: note: You can use "if match is not None" to guard against a None value
+ web/gen/tflow_js.py:31: note: You can use "if tf_http.response is not None" to guard against a None value

steam.py (https://github.com/Gobot1234/steam.py)
+ steam/id.py:558: note: You can use "if session is not None" to guard against a None value

discord.py (https://github.com/Rapptz/discord.py)
+ discord/appinfo.py:464: note: You can use "if guild_install_permissions is not None" to guard against a None value
+ discord/appinfo.py:484: note: You can use "if user_install_permissions is not None" to guard against a None value
+ discord/guild.py:3413: note: You can use "if channel is not None" to guard against a None value

ibis (https://github.com/ibis-project/ibis)
+ ibis/backends/sql/datatypes.py:1371: note: You can use "if scale is not None" to guard against a None value
+ ibis/expr/types/generic.py:1464: note: You can use "if data_mapper is not None" to guard against a None value
+ ibis/expr/types/generic.py:1478: note: You can use "if data_mapper is not None" to guard against a None value
+ ibis/expr/types/generic.py:1664: note: You can use "if data_mapper is not None" to guard against a None value
+ ibis/expr/types/generic.py:1689: note: You can use "if data_mapper is not None" to guard against a None value
+ ibis/expr/types/relations.py:595: note: You can use "if data_mapper is not None" to guard against a None value
+ ibis/expr/types/relations.py:610: note: You can use "if data_mapper is not None" to guard against a None value
+ ibis/expr/types/relations.py:1474: note: You can use "if metrics is not None" to guard against a None value
+ ibis/expr/types/relations.py:1475: note: You can use "if metrics is not None" to guard against a None value
+ ibis/expr/types/relations.py:4527: note: You can use "if match_result is not None" to guard against a None value
+ ibis/backends/databricks/__init__.py:217: note: You can use "if schema is not None" to guard against a None value
+ ibis/backends/oracle/tests/conftest.py:146: note: You can use "if schema is not None" to guard against a None value
+ ibis/backends/druid/tests/conftest.py:86: note: You can use "if match is not None" to guard against a None value
+ ibis/backends/sqlite/__init__.py:522: note: You can use "if obj is not None" to guard against a None value
+ ibis/backends/sqlite/__init__.py:535: note: You can use "if obj is not None" to guard against a None value
+ ibis/backends/clickhouse/__init__.py:681: note: You can use "if obj is not None" to guard against a None value
+ ibis/backends/materialize/__init__.py:837: note: You can use "if connector is not None" to guard against a None value

trio (https://github.com/python-trio/trio)
+ src/trio/_util.py:301: note: You can use "if agen.ag_frame is not None" to guard against a None value
+ src/trio/_core/_tests/test_asyncgen.py:309: note: You can use "if agen.ag_frame is not None" to guard against a None value
+ src/trio/_core/_tests/test_asyncgen.py:313: note: You can use "if agen.ag_frame is not None" to guard against a None value

werkzeug (https://github.com/pallets/werkzeug)
+ tests/test_wrappers.py:178: note: You can use "if a is not None" to guard against a None value
+ tests/test_wrappers.py:179: note: You can use "if a is not None" to guard against a None value
+ tests/test_wrappers.py:180: note: You can use "if a is not None" to guard against a None value
+ tests/test_wrappers.py:188: note: You can use "if a is not None" to guard against a None value
+ tests/test_wrappers.py:189: note: You can use "if a is not None" to guard against a None value
+ tests/test_wrappers.py:190: note: You can use "if a is not None" to guard against a None value
+ tests/test_wrappers.py:1060: note: You can use "if req.range is not None" to guard against a None value
+ tests/test_wrappers.py:1063: note: You can use "if req.range is not None" to guard against a None value
+ tests/test_test.py:164: note: You can use "if b.input_stream is not None" to guard against a None value
+ tests/test_test.py:166: note: You can use "if b.input_stream is not None" to guard against a None value
+ tests/test_test.py:302: note: You can use "if request.authorization is not None" to guard against a None value
+ tests/test_test.py:303: note: You can use "if request.authorization is not None" to guard against a None value
+ tests/test_routing.py:710: note: You can use "if rule.methods is not None" to guard against a None value
+ tests/test_routing.py:712: note: You can use "if rule.methods is not None" to guard against a None value
+ tests/test_local.py:191: note: You can use "if local.LocalProxy.__doc__ is not None" to guard against a None value
+ tests/test_http.py:159: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:160: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:161: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:164: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:165: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:166: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:169: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:170: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:171: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:183: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:184: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:185: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:186: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:187: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:188: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:189: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:190: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:191: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:192: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:202: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:203: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:204: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:205: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:206: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:207: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:208: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:216: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:222: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:223: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:228: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:229: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:253: note: You can use "if wa is not None" to guard against a None value
+ tests/test_http.py:254: note: You can use "if wa is not None" to guard against a None value
+ tests/test_http.py:255: note: You can use "if wa is not None" to guard against a None value
+ tests/test_http.py:256: note: You can use "if wa is not None" to guard against a None value
+ tests/test_http.py:264: note: You can use "if wa is not None" to guard against a None value
+ tests/test_http.py:265: note: You can use "if wa is not None" to guard against a None value
+ tests/test_http.py:266: note: You can use "if wa is not None" to guard against a None value
+ tests/test_http.py:267: note: You can use "if wa is not None" to guard against a None value
+ tests/test_http.py:268: note: You can use "if wa is not None" to guard against a None value
+ tests/test_http.py:277: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:278: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:283: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:284: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:636: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:637: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:638: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:641: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:642: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:643: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:646: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:647: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:648: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:651: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:652: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:653: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:656: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:657: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:658: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:677: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:678: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:679: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:680: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:681: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:690: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:691: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:692: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:693: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:694: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:697: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:698: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:699: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:700: note: You can use "if rv is not None" to guard against a None value
+ tests/test_debug.py:281: note: You can use "if e.__context__ is not None" to guard against a None value
+ tests/test_datastructures.py:1108: note: You can use "if r is not None" to guard against a None value

scipy (https://github.com/scipy/scipy)
+ scipy/_lib/_array_api.py:631: note: You can use "if xp is not None" to guard against a None value
+ scipy/_lib/_array_api.py:632: note: You can use "if xp is not None" to guard against a None value
+ scipy/spatial/transform/_rigid_transform_xp.py:321: note: You can use "if indexer is not None" to guard against a None value
+ scipy/spatial/transform/_rotation.py:2222: note: You can use "if indexer is not None" to guard against a None value
+ scipy/spatial/transform/_rotation.py:2224: note: You can use "if indexer is not None" to guard against a None value
+ scipy/spatial/transform/_rigid_transform.py:1388: note: You can use "if indexer is not None" to guard against a None value
+ scipy/spatial/transform/_rigid_transform.py:1390: note: You can use "if indexer is not None" to guard against a None value

pyodide (https://github.com/pyodide/pyodide)
+ pyodide-build/pyodide_build/out_of_tree/venv.py:463: note: You can use "if self.venv_bin is not None" to guard against a None value
+ pyodide-build/pyodide_build/out_of_tree/venv.py:713: note: You can use "if self.venv_bin is not None" to guard against a None value
+ pyodide-build/pyodide_build/tests/recipe/test_unvendor.py:17: note: You can use "if test_tar_path is not None" to guard against a None value
+ pyodide-build/pyodide_build/tests/recipe/test_unvendor.py:18: note: You can use "if test_tar_path is not None" to guard against a None value
+ pyodide-build/pyodide_build/tests/recipe/test_unvendor.py:54: note: You can use "if test_tar_path is not None" to guard against a None value
+ pyodide-build/pyodide_build/tests/recipe/test_unvendor.py:55: note: You can use "if test_tar_path is not None" to guard against a None value

kornia (https://github.com/kornia/kornia)
+ kornia/enhance/histogram.py:236: note: You can use "if image is not None" to guard against a None value
+ kornia/enhance/histogram.py:239: note: You can use "if image is not None" to guard against a None value
+ kornia/enhance/histogram.py:260: note: You can use "if image is not None" to guard against a None value
+ kornia/enhance/histogram.py:263: note: You can use "if image is not None" to guard against a None value
+ kornia/enhance/histogram.py:268: note: You can use "if image is not None" to guard against a None value
+ kornia/enhance/histogram.py:270: note: You can use "if image is not None" to guard against a None value
+ kornia/models/kimi_vl/model.py:96: note: You can use "if config.vision_config is not None" to guard against a None value
+ kornia/models/siglip2/builder.py:67: note: You can use "if config.text_config is not None" to guard against a None value
+ kornia/models/siglip2/builder.py:68: note: You can use "if config.text_config is not None" to guard against a None value

apprise (https://github.com/caronc/apprise)
+ apprise/apprise_attachment.py:217: note: You can use "if instance is not None" to guard against a None value
+ apprise/apprise_attachment.py:219: note: You can use "if instance is not None" to guard against a None value
+ apprise/apprise_attachment.py:223: note: You can use "if instance is not None" to guard against a None value
+ apprise/apprise_attachment.py:224: note: You can use "if instance is not None" to guard against a None value
+ tests/test_utils_socket.py:751: note: You can use "if s._sock is not None" to guard against a None value
+ tests/test_plugin_xmpp.py:602: note: You can use "if self.loop is not None" to guard against a None value
+ tests/test_plugin_xmpp.py:772: note: You can use "if self.disconnected is not None" to guard against a None value
+ tests/test_plugin_xmpp.py:773: note: You can use "if self.disconnected is not None" to guard against a None value
+ tests/test_plugin_xmpp.py:949: note: You can use "if self.loop is not None" to guard against a None value
+ tests/test_plugin_xmpp.py:1145: note: You can use "if self.loop is not None" to guard against a None value
+ tests/test_plugin_xmpp.py:1233: note: You can use "if self.loop is not None" to guard against a None value
+ tests/test_plugin_xmpp.py:2582: note: You can use "if client is not None" to guard against a None value
+ tests/test_plugin_xmpp.py:2603: note: You can use "if started is not None" to guard against a None value

materialize (https://github.com/MaterializeInc/materialize)
+ misc/python/materialize/cli/cloudbench.py:163: note: You can use "if r is not None" to guard against a None value
+ misc/python/materialize/cli/cloudbench.py:164: note: You can use "if r is not None" to guard against a None value
+ misc/python/materialize/lint/lint.py:141: note: You can use "if thread.duration is not None" to guard against a None value
+ misc/python/materialize/parallel_workload/parallel_workload.py:374: note: You can use "if worker.exe is not None" to guard against a None value

pip (https://github.com/pypa/pip)
+ src/pip/_internal/network/utils.py:65: note: You can use "if response.raw is not None" to guard against a None value
+ src/pip/_internal/network/utils.py:95: note: You can use "if response.raw is not None" to guard against a None value
+ src/pip/_internal/network/auth.py:527: note: You can use "if resp.raw is not None" to guard against a None value
+ src/pip/_internal/network/auth.py:550: note: You can use "if resp.request is not None" to guard against a None value
+ src/pip/_internal/index/collector.py:83: note: You can use "if response.request is not None" to guard against a None value

check-jsonschema (https://github.com/python-jsonschema/check-jsonschema)
+ src/check_jsonschema/cli/param_types.py:104: note: You can use "if m is not None" to guard against a None value
+ src/check_jsonschema/cli/param_types.py:105: note: You can use "if m is not None" to guard against a None value

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.

Better error message when union may not have been narrowed

1 participant