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
Provide hint when Union type with None may not have been narrowed #17178
Open
angelawuuu
wants to merge
14
commits into
python:master
Choose a base branch
from
kr321:union
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
… with warning message
… with warning message
This reverts commit 0c28fad.
…pes missing an attribute is generated
…ining about None type missing an attribute is generated
…utes on union types
…n't have an attribute
This comment has been minimized.
This comment has been minimized.
Diff from mypy_primer, showing the effect of this PR on open source code: pip (https://github.com/pypa/pip)
+ src/pip/_internal/network/utils.py:63: note: You can use "if response.raw is not None" to guard against a None value
+ src/pip/_internal/network/utils.py:93: note: You can use "if response.raw is not None" to guard against a None value
+ src/pip/_internal/network/auth.py:521: note: You can use "if resp.raw is not None" to guard against a None value
+ src/pip/_internal/network/auth.py:544: note: You can use "if resp.request is not None" to guard against a None value
+ src/pip/_internal/network/session.py:408: note: You can use "if self.auth is not None" to guard against a None value
+ src/pip/_internal/index/collector.py:88: note: You can use "if response.request is not None" to guard against a None value
+ src/pip/_internal/cli/req_command.py:150: note: You can use "if session.auth is not None" to guard against a None value
+ src/pip/_internal/cli/req_command.py:151: note: You can use "if session.auth is not None" to guard against a None value
dragonchain (https://github.com/dragonchain/dragonchain)
+ dragonchain/broadcast_processor/broadcast_functions.py:95:32: note: You can use "if <variable name> is not None" to guard against a None value
+ dragonchain/lib/authorization.py:315:19: note: You can use "if <variable name> is not None" to guard against a None value
+ dragonchain/lib/authorization.py:317:25: note: You can use "if <variable name> is not None" to guard against a None value
+ dragonchain/lib/authorization.py:340:31: note: You can use "if <variable name> 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:90: note: You can use "if m is not None" to guard against a None value
+ src/check_jsonschema/cli/param_types.py:91: note: You can use "if m 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
Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ tanjun/dependencies/limiters.py:819: note: You can use "if resource is not None" to guard against a None value
sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/builders/html/__init__.py:441:16: note: You can use "if self._publisher.writer is not None" to guard against a None value
pytest (https://github.com/pytest-dev/pytest)
+ src/_pytest/_code/code.py:1077: note: You can use "if e is not None" to guard against a None value
+ src/_pytest/_code/code.py:1083: note: You can use "if e is not None" to guard against a None value
+ testing/_py/test_local.py:858: note: You can use "if x is not None" to guard against a None value
+ testing/_py/test_local.py:861: note: You can use "if x is not None" to guard against a None value
+ testing/_py/test_local.py:912: note: You can use "if x is not None" to guard against a None value
+ testing/_py/test_local.py:914: note: You can use "if y is not None" to guard against a None value
+ testing/_py/test_local.py:923: note: You can use "if x is not None" to guard against a None value
+ testing/_py/test_local.py:924: note: You can use "if x is not None" to guard against a None value
+ testing/_py/test_local.py:929: note: You can use "if x is not None" to guard against a None value
+ testing/_py/test_local.py:940: note: You can use "if x is not None" to guard against a None value
+ testing/_py/test_local.py:1281: note: You can use "if cmd is not None" to guard against a None value
+ testing/_py/test_local.py:1283: note: You can use "if cmd is not None" to guard against a None value
+ testing/_py/test_local.py:1284: note: You can use "if x is not None" to guard against a None value
operator (https://github.com/canonical/operator)
+ ops/lib/__init__.py:266: note: You can use "if self.spec.loader is not None" to guard against a None value
kornia (https://github.com/kornia/kornia)
+ kornia/enhance/histogram.py:217: note: You can use "if image is not None" to guard against a None value
+ kornia/enhance/histogram.py:220: note: You can use "if image is not None" to guard against a None value
+ kornia/enhance/histogram.py:241: note: You can use "if image is not None" to guard against a None value
+ kornia/enhance/histogram.py:244: note: You can use "if image is not None" to guard against a None value
+ kornia/enhance/histogram.py:249: note: You can use "if image is not None" to guard against a None value
+ kornia/enhance/histogram.py:251: note: You can use "if image is not None" to guard against a None value
werkzeug (https://github.com/pallets/werkzeug)
+ 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:181: 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:191: note: You can use "if a is not None" to guard against a None value
+ tests/test_wrappers.py:1078: note: You can use "if req.range is not None" to guard against a None value
+ tests/test_wrappers.py:1081: note: You can use "if req.range 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:168: note: You can use "if b.input_stream is not None" to guard against a None value
+ tests/test_test.py:306: note: You can use "if request.authorization is not None" to guard against a None value
+ tests/test_test.py:307: note: You can use "if request.authorization is not None" to guard against a None value
+ tests/test_routing.py:601: note: You can use "if rule.methods is not None" to guard against a None value
+ tests/test_routing.py:603: note: You can use "if rule.methods is not None" to guard against a None value
+ tests/test_routing.py:1310: note: You can use "if None 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:152: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:153: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:154: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:157: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:158: note: You can use "if a 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:162: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:163: 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:176: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:177: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:178: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:179: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:180: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:181: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:182: 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:195: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:196: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:197: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:198: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:199: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:200: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:201: 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 <variable name> is not None" to guard against a None value
+ tests/test_http.py:211: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:212: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:217: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:218: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:242: note: You can use "if wa is not None" to guard against a None value
+ tests/test_http.py:243: note: You can use "if wa is not None" to guard against a None value
+ tests/test_http.py:244: note: You can use "if wa is not None" to guard against a None value
+ tests/test_http.py:245: note: You can use "if wa 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:257: note: You can use "if wa is not None" to guard against a None value
+ tests/test_http.py:259: note: You can use "if <variable name> is not None" to guard against a None value
+ tests/test_http.py:266: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:267: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:272: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:273: note: You can use "if a is not None" to guard against a None value
+ tests/test_http.py:623: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:624: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:625: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:628: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:629: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:630: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:633: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:634: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:635: 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:639: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:640: 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:644: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:645: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:664: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:665: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:666: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:667: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:668: 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:684: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:685: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:686: note: You can use "if rv is not None" to guard against a None value
+ tests/test_http.py:687: 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:1189: note: You can use "if r is not None" to guard against a None value
+ tests/conftest.py:86: note: You can use "if self is not None" to guard against a None value
+ tests/conftest.py:123: note: You can use "if client.log is not None" to guard against a None value
discord.py (https://github.com/Rapptz/discord.py)
+ discord/guild.py:3232: note: You can use "if channel is not None" to guard against a None value
streamlit (https://github.com/streamlit/streamlit)
+ lib/tests/streamlit/streamlit_test.py:61:30: note: You can use "if <variable name> is not None" to guard against a None value
+ lib/tests/streamlit/runtime/scriptrunner/script_requests_test.py:116:32: note: You can use "if <variable name> is not None" to guard against a None value
+ lib/tests/streamlit/runtime/scriptrunner/script_requests_test.py:119:31: note: You can use "if <variable name> is not None" to guard against a None value
+ lib/tests/streamlit/runtime/scriptrunner/script_requests_test.py:141:32: note: You can use "if <variable name> is not None" to guard against a None value
+ lib/tests/streamlit/runtime/scriptrunner/script_requests_test.py:142:31: note: You can use "if <variable name> is not None" to guard against a None value
+ lib/tests/streamlit/runtime/scriptrunner/script_requests_test.py:163:32: note: You can use "if <variable name> is not None" to guard against a None value
+ lib/tests/streamlit/runtime/scriptrunner/script_requests_test.py:164:31: note: You can use "if <variable name> is not None" to guard against a None value
+ lib/tests/streamlit/logger_test.py:104:21: note: You can use "if None is not None" to guard against a None value
+ lib/tests/streamlit/logger_test.py:108:21: note: You can use "if None is not None" to guard against a None value
+ lib/tests/streamlit/config_test.py:402:23: note: You can use "if config._config_options is not None" to guard against a None value
+ lib/tests/streamlit/runtime/websocket_session_manager_test.py:136:27: note: You can use "if original_session_info is not None" to guard against a None value
+ lib/tests/streamlit/runtime/websocket_session_manager_test.py:139:9: note: You can use "if original_session_info is not None" to guard against a None value
+ lib/tests/streamlit/runtime/websocket_session_manager_test.py:145:9: note: You can use "if original_session_info is not None" to guard against a None value
+ lib/tests/streamlit/runtime/websocket_session_manager_test.py:146:9: note: You can use "if original_session_info is not None" to guard against a None value
+ lib/tests/streamlit/runtime/websocket_session_manager_test.py:153:9: note: You can use "if original_session_info is not None" to guard against a None value
+ lib/tests/streamlit/runtime/websocket_session_manager_test.py:154:9: note: You can use "if original_session_info is not None" to guard against a None value
+ lib/tests/streamlit/runtime/websocket_session_manager_test.py:163:16: note: You can use "if reconnected_session_info is not None" to guard against a None value
+ lib/tests/streamlit/runtime/websocket_session_manager_test.py:163:52: note: You can use "if original_session_info is not None" to guard against a None value
+ lib/tests/streamlit/runtime/websocket_session_manager_test.py:165:16: note: You can use "if reconnected_session_info is not None" to guard against a None value
+ lib/tests/streamlit/runtime/websocket_session_manager_test.py:168:16: note: You can use "if reconnected_session_info is not None" to guard against a None value
+ lib/tests/streamlit/runtime/websocket_session_manager_test.py:178:16: note: You can use "if active_session_info is not None" to guard against a None value
+ lib/tests/streamlit/runtime/websocket_session_manager_test.py:219:9: note: You can use "if session_info is not None" to guard against a None value
+ lib/tests/streamlit/runtime/websocket_session_manager_test.py:234:9: note: You can use "if session_info is not None" to guard against a None value
+ lib/tests/streamlit/runtime/websocket_session_manager_test.py:243:16: note: You can use "if session_info is not None" to guard against a None value
+ lib/tests/streamlit/runtime/websocket_session_manager_test.py:253:16: note: You can use "if session_info is not None" to guard against a None value
+ lib/tests/streamlit/runtime/runtime_test.py:233:19: note: You can use "if <variable name> is not None" to guard against a None value
+ lib/tests/streamlit/runtime/runtime_test.py:253:19: note: You can use "if <variable name> is not None" to guard against a None value
+ lib/tests/streamlit/runtime/runtime_test.py:342:27: note: You can use "if <variable name> is not None" to guard against a None value
+ lib/tests/streamlit/runtime/runtime_test.py:370:23: note: You can use "if <variable name> is not None" to guard against a None value
+ lib/tests/streamlit/runtime/runtime_test.py:396:23: note: You can use "if <variable name> is not None" to guard against a None value
+ lib/tests/streamlit/runtime/app_session_test.py:488:9: note: You can use "if session._local_sources_watcher is not None" to guard against a None value
+ lib/tests/streamlit/runtime/scriptrunner/script_runner_test.py:1138:24: note: You can use "if widget is not None" to guard against a None value
+ lib/tests/streamlit/form_test.py:251:33: note: You can use "if form_data is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:310:26: note: You can use "if dg._cursor is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:311:26: note: You can use "if dg._cursor is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:317:25: note: You can use "if dg._cursor is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:318:26: note: You can use "if dg._cursor is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:336:26: note: You can use "if c1 is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:336:46: note: You can use "if c2 is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:337:26: note: You can use "if c1 is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:337:37: note: You can use "if c2 is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:338:26: note: You can use "if c1 is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:338:43: note: You can use "if c2 is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:339:26: note: You can use "if c1 is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:339:37: note: You can use "if c2 is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:350:29: note: You can use "if dg._cursor is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:359:29: note: You can use "if dg._cursor is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:370:31: note: You can use "if dg._cursor is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:388:9: note: You can use "if ctx is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:398:9: note: You can use "if ctx is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:399:9: note: You can use "if ctx is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:407:9: note: You can use "if ctx is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:408:9: note: You can use "if ctx is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:423:26: note: You can use "if container._cursor is not None" to guard against a None value
+ lib/tests/streamlit/delta_generator_test.py:442:30: note: You can use "if column._cursor is not None" to guard against a None value
+ lib/tests/streamlit/web/server/server_test.py:215:26: note: You can use "if ws_client.headers is not None" to guard against a None value
+ lib/tests/streamlit/web/server/server_test.py:231:31: note: You can use "if ws_client.headers is not None" to guard against a None value
+ lib/tests/streamlit/runtime/metrics_util_test.py:179:9: note: You can use "if ctx is not None" to guard against a None value
+ lib/tests/streamlit/runtime/state/widgets_test.py:473:17: note: You can use "if <variable name> is not None" to guard against a None value
+ lib/tests/streamlit/runtime/state/widgets_test.py:480:17: note: You can use "if <variable name> is not None" to guard against a None value
+ lib/tests/streamlit/runtime/state/widgets_test.py:488:17: note: You can use "if <variable name> is not None" to guard against a None value
+ lib/tests/streamlit/runtime/state/widgets_test.py:495:17: note: You can use "if <variable name> is not None" to guard against a None value
+ lib/tests/streamlit/runtime/state/session_state_test.py:177:16: note: You can use "if serialized is not None" to guard against a None value
+ lib/tests/streamlit/runtime/state/session_state_test.py:178:16: note: You can use "if serialized is not None" to guard against a None value
+ lib/tests/streamlit/runtime/state/session_state_test.py:182:16: note: You can use "if serialized is not None" to guard against a None value
+ lib/tests/streamlit/runtime/state/session_state_test.py:183:16: note: You can use "if serialized is not None" to guard against a None value
+ lib/tests/streamlit/runtime/state/session_state_test.py:200:16: note: You can use "if serialized is not None" to guard against a None value
+ lib/tests/streamlit/runtime/state/session_state_test.py:201:21: note: You can use "if serialized is not None" to guard against a None value
+ lib/tests/streamlit/runtime/state/session_state_test.py:215:16: note: You can use "if serialized is not None" to guard against a None value
+ lib/tests/streamlit/runtime/state/session_state_test.py:216:16: note: You can use "if serialized is not None" to guard against a None value
+ lib/tests/streamlit/runtime/state/session_state_test.py:239:9: note: You can use "if metadata.callback is not None" to guard against a None value
... (truncated 1 lines) ...
ibis (https://github.com/ibis-project/ibis)
+ ibis/expr/types/generic.py:1225: note: You can use "if data_mapper is not None" to guard against a None value
+ ibis/expr/types/generic.py:1395: note: You can use "if data_mapper is not None" to guard against a None value
+ ibis/expr/types/relations.py:232: note: You can use "if data_mapper is not None" to guard against a None value
+ ibis/expr/types/relations.py:1149: note: You can use "if metrics is not None" to guard against a None value
+ ibis/expr/types/relations.py:1150: note: You can use "if metrics is not None" to guard against a None value
+ ibis/expr/types/relations.py:3833: note: You can use "if match_result is not None" to guard against a None value
+ ibis/expr/types/relations.py:4248: note: You can use "if names is not None" to guard against a None value
+ ibis/expr/types/relations.py:4254: note: You can use "if names is not None" to guard against a None value
+ ibis/expr/types/relations.py:4256: note: You can use "if names is not None" to guard against a None value
+ ibis/backends/sql/datatypes.py:1030: note: You can use "if scale is not None" to guard against a None value
+ ibis/backends/tests/base.py:104: note: You can use "if <variable name> is not None" to guard against a None value
+ ibis/examples/gen_registry.py:328: note: You can use "if <variable name> is not None" to guard against a None value
+ ibis/backends/druid/tests/conftest.py:87: note: You can use "if match is not None" to guard against a None value
+ ibis/backends/datafusion/__init__.py:290: note: You can use "if catalog is not None" to guard against a None value
+ ibis/backends/datafusion/__init__.py:292: note: You can use "if catalog is not None" to guard against a None value
+ ibis/backends/datafusion/__init__.py:294: note: You can use "if database is not None" to guard against a None value
+ ibis/backends/clickhouse/__init__.py:258: note: You can use "if expr 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
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.
Fixes #17036
When a union includes
None
, new users may not know they need anis not None
check before accessing attributes. For example, the following code:previously (on the master branch) generated this error message:
which may be ambiguous since
x
is never explicitly defined asNone
.With this PR, the message remains, but we add a suggestion for how to fix the error:
This is possible by checking if
None
is part of the union when an error signaling a type doesn't have an attribute is triggered and displays the corresponding hint if it is.