Repository navigation
Conversation
A note attached to a parent error (parent_error) survived when the parent error was ignored by a 'type: ignore' comment on a different line of the same multi-line expression, because the note's own origin_span does not include the ignored line. Suppress such notes in add_error_info when the parent error is ignored on the parent's lines. Also attach the union operand notes to their parent error (unsupported operand types) so they take part in that logic, and normalize ErrorInfo.origin_span to a list so it can be inspected more than once. Fixes python#22271
for more information, see https://pre-commit.ci
Contributor
|
Diff from mypy_primer, showing the effect of this PR on open source code: colour (https://github.com/colour-science/colour)
- colour/utilities/array.py:4405: note: Right operand is of type "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]"
- colour/utilities/array.py:4751: note: Right operand is of type "Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]"
core (https://github.com/home-assistant/core)
+ .../projects/_core_venv/lib/python3.14/site-packages/cryptography/x509/name.py:141: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
+ https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
+ Please report a bug at https://github.com/python/mypy/issues
+ version: 2.5.0+dev.d50f709aea448f9db3685fb3f74a42999986a8f5
+ .../projects/_core_venv/lib/python3.14/site-packages/cryptography/x509/name.py:141: note: use --pdb to drop into pdb
+ error: INTERNAL ERROR -- Please try using mypy master on GitHub:
+ https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
+ Please report a bug at https://github.com/python/mypy/issues
+ version: 2.5.0+dev.d50f709aea448f9db3685fb3f74a42999986a8f5
+ note: use --pdb to drop into pdb
+ Traceback (most recent call last):
+ File "<frozen runpy>", line 203, in _run_module_as_main
+ File "<frozen runpy>", line 88, in _run_code
+ File "/build_worker/__main__.py", line 6, in <module>
+ console_entry()
+ File "/build_worker/worker.py", line 379, in console_entry
+ main(sys.argv[1:])
+ File "/build_worker/worker.py", line 144, in main
+ serve(server, ctx)
+ File "/build_worker/worker.py", line 246, in serve
+ scc_result = process_stale_scc_interface(
+ File "/build.py", line 5011, in process_stale_scc_interface
+ graph[id].type_check_first_pass(recurse_into_functions=False)
+ File "/build.py", line 3482, in type_check_first_pass
+ self.type_checker().check_first_pass(recurse_into_functions=recurse_into_functions)
+ File "/checker.py", line 636, in check_first_pass
+ self.accept(d)
+ File "/checker.py", line 783, in accept
+ stmt.accept(self)
+ File "/nodes.py", line 1739, in accept
+ return visitor.visit_class_def(self)
+ File "/checker.py", line 2854, in visit_class_def
+ self.accept(defn.defs)
+ File "/checker.py", line 783, in accept
+ stmt.accept(self)
+ File "/nodes.py", line 1834, in accept
+ return visitor.visit_block(self)
+ File "/checker.py", line 3378, in visit_block
+ self.accept(s)
+ File "/checker.py", line 783, in accept
+ stmt.accept(self)
+ File "/nodes.py", line 1169, in accept
+ return visitor.visit_func_def(self)
+ File "/checker.py", line 1371, in visit_func_def
+ self.visit_func_def_impl(defn)
+ File "/checker.py", line 1375, in visit_func_def_impl
+ self.check_func_item(defn, name=defn.name)
+ File "/checker.py", line 1408, in check_func_item
+ self.check_func_def(defn, typ, name, allow_empty)
+ File "/checker.py", line 1593, in check_func_def
+ self.accept(item.body)
+ File "/checker.py", line 783, in accept
+ stmt.accept(self)
+ File "/nodes.py", line 1834, in accept
+ return visitor.visit_block(self)
+ File "/checker.py", line 3378, in visit_block
+ self.accept(s)
+ File "/checker.py", line 783, in accept
+ stmt.accept(self)
+ File "/nodes.py", line 2109, in accept
+ return visitor.visit_if_stmt(self)
+ File "/checker.py", line 5470, in visit_if_stmt
+ t = get_proper_type(self.expr_checker.accept(e))
+ File "/checkexpr.py", line 6324, in accept
+ typ = node.accept(self) # r-value type, when interpreted as a value expression
+ File "/nodes.py", line 2752, in accept
+ return visitor.visit_comparison_expr(self)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
+ File "/checkexpr.py", line 3866, in visit_comparison_expr
+ sub_result, method_type = self.check_op(
+ ~~~~~~~~~~~~~^
+ method, left_type, right, e, allow_reverse=True
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ )
+ ^
+ File "/checkexpr.py", line 4438, in check_op
+ self.msg.warn_operand_was_from_union(
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
+ "Left", base_type, context=recent_context, parent_error=err
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ )
+ ^
+ File "/messages.py", line 1791, in warn_operand_was_from_union
+ self.note(
+ ~~~~~~~~~^
+ f"{side} operand is of type {format_type(original, self.options)}",
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ ...<2 lines>...
+ parent_error=parent_error,
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ )
+ ^
+ File "/messages.py", line 295, in note
+ self.report(
+ ~~~~~~~~~~~^
+ msg,
+ ^^^^
+ ...<5 lines>...
+ parent_error=parent_error,
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ )
+ ^
+ File "/messages.py", line 260, in report
+ return self.errors.report(
+ ~~~~~~~~~~~~~~~~~~^
+ context.line if context else -1,
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ ...<8 lines>...
+ parent_error=parent_error,
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ )
+ ^
+ File "/errors.py", line 657, in report
+ assert code == parent_error.code, "Must have same error code as parent"
+ ^^^^^^^^^^^^^^^^^^^^^^^^^
+ AssertionError: Must have same error code as parent
+
+ Traceback (most recent call last):
+ File "/build.py", line 1380, in receive_worker_message
+ return receive(self.workers[idx].conn)
+ File "/ipc.py", line 496, in receive
+ raise OSError("No data received")
+ OSError: No data received
+
+ The above exception was the direct cause of the following exception:
+
+ Traceback (most recent call last):
+ File "", line 6, in <module>
+ sys.exit(console_entry())
+ File "/__main__.py", line 16, in console_entry
+ main()
+ ~~~~^^
+ File "/main.py", line 167, in main
+ res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
+ ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ File "/main.py", line 257, in run_build
+ res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
+ File "/build.py", line 427, in build
+ result = build_inner(
+ sources,
+ ...<9 lines>...
+ metastore,
+ )
+ File "/build.py", line 542, in build_inner
+ graph = dispatch(sources, manager, stdout, connect_threads)
+ File "/build.py", line 4224, in dispatch
+ process_graph(graph, manager)
+ ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
+ File "/build.py", line 4692, in process_graph
+ done, still_working, results = manager.wait_for_done(graph)
+ ~~~~~~~~~~~~~~~~~~~~~^^^^^^^
+ File "/build.py", line 1476, in wait_for_done
+ return self.wait_for_done_workers(graph)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
+ File "/build.py", line 1495, in wait_for_done_workers
+ buf = self.receive_worker_message(idx)
+ File "/build.py", line 1388, in receive_worker_message
+ raise OSError(
+ f"Worker {idx} disconnected before sending data ({exit_status})"
+ ) from exc
+ OSError: Worker 1 disconnected before sending data (exit code 2)
+
- homeassistant/components/airos/config_flow.py:103: error: Variable "homeassistant.components.airos.config_flow.AirOSDeviceDetect" is not valid as a type [valid-type]
- homeassistant/components/airos/config_flow.py:103: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
- homeassistant/components/alexa_devices/coordinator.py:249: error: Returning Any from function declared to return "dict[str, Any]" [no-any-return]
- homeassistant/components/apple_tv/config_flow.py:146: error: Returning Any from function declared to return "str | None" [no-any-return]
- homeassistant/components/asuswrt/bridge.py:239: error: Returning Any from function declared to return "bool" [no-any-return]
- homeassistant/components/asuswrt/bridge.py:332: error: Returning Any from function declared to return "tuple[float | None, float | None]" [no-any-return]
- homeassistant/components/asuswrt/bridge.py:337: error: Returning Any from function declared to return "tuple[float, float]" [no-any-return]
- homeassistant/components/asuswrt/bridge.py:342: error: Returning Any from function declared to return "list[float]" [no-any-return]
- homeassistant/components/asuswrt/bridge.py:347: error: Returning Any from function declared to return "dict[str, float]" [no-any-return]
- homeassistant/components/asuswrt/bridge.py:389: error: Returning Any from function declared to return "bool" [no-any-return]
- homeassistant/components/cloud/tts.py:332: error: Returning Any from function declared to return "str" [no-any-return]
- homeassistant/components/cloud/tts.py:490: error: Returning Any from function declared to return "str | None" [no-any-return]
- homeassistant/components/data_grand_lyon/config_flow.py:305: error: Returning Any from function declared to return "str" [no-any-return]
- homeassistant/components/data_grand_lyon/config_flow.py:403: error: Returning Any from function declared to return "str" [no-any-return]
- homeassistant/components/engie_be/__init__.py:66: error: Returning Any from function declared to return "bool | None" [no-any-return]
- homeassistant/components/evohome/coordinator.py:67: error: Unused "type: ignore" comment [unused-ignore]
- homeassistant/components/evohome/coordinator.py:267: error: Unused "type: ignore" comment [unused-ignore]
- homeassistant/components/evohome/storage.py:34: error: Class cannot subclass "AbstractTokenManager" (has type "Any") [misc]
- homeassistant/components/evohome/storage.py:34: error: Class cannot subclass "AbstractSessionManager" (has type "Any") [misc]
- homeassistant/components/evohome/storage.py:59: error: Returning Any from function declared to return "str" [no-any-return]
- homeassistant/components/evohome/storage.py:71: error: Returning Any from function declared to return "str" [no-any-return]
- homeassistant/components/evohome/storage.py:90: error: Unused "type: ignore" comment [unused-ignore]
- homeassistant/components/evohome/storage.py:94: error: TypedDict key must be a string literal; expected one of ("session_id", "session_id_expires") [literal-required]
- homeassistant/components/evohome/storage.py:100: error: Argument 1 to "fromisoformat" of "date" has incompatible type "object"; expected "str" [arg-type]
- homeassistant/components/intent/timers.py:323: error: Returning Any from function declared to return "str" [no-any-return]
- homeassistant/components/lifx/coordinator.py:97: error: Returning Any from function declared to return "str" [no-any-return]
- homeassistant/components/lifx/coordinator.py:119: error: Returning Any from function declared to return "int | None" [no-any-return]
- homeassistant/components/lifx/coordinator.py:130: error: Returning Any from function declared to return "str | None" [no-any-return]
- homeassistant/components/matrix/__init__.py:131: error: Returning Any from function declared to return "tuple[int, int]" [no-any-return]
- homeassistant/components/midea/config_flow.py:65: error: Returning Any from function declared to return "bool" [no-any-return]
- homeassistant/components/midea/config_flow.py:500: error: Returning Any from function declared to return "dict[str, Any]" [no-any-return]
- homeassistant/components/mijn_farmad_apotheek/services.py:119: error: Returning Any from function declared to return "str" [no-any-return]
- homeassistant/components/mijn_farmad_apotheek/services.py:234: error: Returning Any from function declared to return "str" [no-any-return]
- homeassistant/components/opower/coordinator.py:569: error: Returning Any from function declared to return "list[Any]" [no-any-return]
- homeassistant/components/opower/coordinator.py:598: error: Returning Any from function declared to return "list[Any]" [no-any-return]
- homeassistant/components/opower/coordinator.py:624: error: Returning Any from function declared to return "list[Any]" [no-any-return]
- homeassistant/components/powerwall/__init__.py:365: error: Returning Any from function declared to return "float | None" [no-any-return]
- homeassistant/components/powerwall/__init__.py:373: error: Returning Any from function declared to return "int | None" [no-any-return]
- homeassistant/components/powerwall/__init__.py:381: error: Returning Any from function declared to return "int | None" [no-any-return]
- homeassistant/components/prometheus/__init__.py:565: error: Returning Any from function declared to return "_MetricBaseT" [no-any-return]
- homeassistant/components/samsungtv/bridge.py:446: error: Returning Any from function declared to return "bool" [no-any-return]
- homeassistant/components/samsungtv/bridge.py:457: error: Unused "type: ignore" comment [unused-ignore]
- homeassistant/components/simplisafe/__init__.py:128: error: Unused "type: ignore" comment [unused-ignore]
- homeassistant/components/victron_gx/config_flow.py:108: error: Returning Any from function declared to return "str" [no-any-return]
- homeassistant/components/wallbox/coordinator.py:112: error: Item "None" of "Response | None" has no attribute "status_code" [union-attr]
- homeassistant/components/wallbox/coordinator.py:155: error: Item "None" of "Response | None" has no attribute "status_code" [union-attr]
- homeassistant/components/wallbox/coordinator.py:229: error: Item "None" of "Response | None" has no attribute "status_code" [union-attr]
- homeassistant/components/wallbox/coordinator.py:262: error: Item "None" of "Response | None" has no attribute "status_code" [union-attr]
- homeassistant/components/wallbox/coordinator.py:268: error: Item "None" of "Response | None" has no attribute "status_code" [union-attr]
- homeassistant/components/wallbox/coordinator.py:292: error: Item "None" of "Response | None" has no attribute "status_code" [union-attr]
- homeassistant/components/wallbox/coordinator.py:298: error: Item "None" of "Response | None" has no attribute "status_code" [union-attr]
- homeassistant/components/wallbox/coordinator.py:322: error: Item "None" of "Response | None" has no attribute "status_code" [union-attr]
- homeassistant/components/wallbox/coordinator.py:351: error: Item "None" of "Response | None" has no attribute "status_code" [union-attr]
- homeassistant/components/wallbox/coordinator.py:357: error: Item "None" of "Response | None" has no attribute "status_code" [union-attr]
- homeassistant/components/wallbox/coordinator.py:379: error: Item "None" of "Response | None" has no attribute "status_code" [union-attr]
- homeassistant/components/wallbox/coordinator.py:398: error: Item "None" of "Response | None" has no attribute "status_code" [union-attr]
- homeassistant/components/wallbox/coordinator.py:404: error: Item "None" of "Response | None" has no attribute "status_code" [union-attr]
- homeassistant/components/wallbox/coordinator.py:428: error: Item "None" of "Response | None" has no attribute "status_code" [union-attr]
- homeassistant/components/xiaomi_ble/config_flow.py:48: error: Returning Any from function declared to return "str" [no-any-return]
- homeassistant/components/zonneplan/coordinator.py:179: error: Returning Any from function declared to return "tuple[Any | None, Any | None]" [no-any-return]
- homeassistant/components/zonneplan/coordinator.py:192: error: Returning Any from function declared to return "tuple[Any | None, Any | None]" [no-any-return]
- homeassistant/auth/__init__.py:636: error: Returning Any from function declared to return "str" [no-any-return]
- homeassistant/auth/jwt_wrapper.py:35: error: Class cannot subclass "PyJWS" (has type "Any") [misc]
- homeassistant/auth/jwt_wrapper.py:45: error: Returning Any from function declared to return "tuple[bytes, bytes, dict[Any, Any], bytes]" [no-any-return]
- homeassistant/auth/jwt_wrapper.py:60: error: Class cannot subclass "PyJWT" (has type "Any") [misc]
- homeassistant/auth/jwt_wrapper.py:108: error: Returning Any from function declared to return "dict[str, Any]" [no-any-return]
- homeassistant/components/assist_pipeline/pipeline.py:370: error: Returning Any from function declared to return "str" [no-any-return]
- homeassistant/components/automation/config.py:107: error: Returning Any from function declared to return "str" [no-any-return]
- homeassistant/components/backup/util.py:444: error: Returning Any from function declared to return "int" [no-any-return]
- homeassistant/components/blueprint/models.py:135: error: Returning Any from function declared to return "str" [no-any-return]
- homeassistant/components/bluetooth/api.py:75: error: Returning Any from function declared to return "int" [no-any-return]
... (truncated 1505 lines) ...
cvxpy (https://github.com/cvxpy/cvxpy)
- cvxpy/lin_ops/backends/base.py:356: note: Both left and right operands are unions
jax (https://github.com/google/jax)
- jax/_src/pallas/mosaic/lowering.py:2174: note: Left operand is of type "int | Squeezed"
freqtrade (https://github.com/freqtrade/freqtrade)
- freqtrade/data/converter/orderflow.py:172: note: Both left and right operands are unions
- freqtrade/strategy/strategy_helper.py:105: note: Left operand is of type "str | bytes | date | timedelta | datetime64[Any] | <7 more items>"
- freqtrade/strategy/strategy_helper.py:106: note: Left operand is of type "str | bytes | date | timedelta | datetime64[Any] | <7 more items>"
- freqtrade/data/btanalysis/trade_parallelism.py:151: note: Right operand is of type "int | Any | datetime64[Any] | timedelta64[Any] | float | complex | floating[Any] | complexfloating[Any, Any]"
- freqtrade/data/btanalysis/trade_parallelism.py:151: note: Right operand is of type "str | bytes | date | datetime | timedelta | <7 more items> | complex | integer[Any] | floating[Any] | complexfloating[Any, Any]"
- freqtrade/data/btanalysis/trade_parallelism.py:156: note: Right operand is of type "int | Any | datetime64[Any] | timedelta64[Any] | float | complex | floating[Any] | complexfloating[Any, Any]"
- freqtrade/data/btanalysis/trade_parallelism.py:156: note: Left operand is of type "str | bytes | date | datetime | timedelta | <7 more items> | complex | integer[Any] | floating[Any] | complexfloating[Any, Any]"
- freqtrade/util/migrations/migrate_wallet_history.py:153: note: Left operand is of type "int | slice[Any, Any, Any] | ndarray[tuple[int], dtype[numpy.bool[builtins.bool]]]"
- freqtrade/optimize/analysis/lookahead.py:83: note: Left operand is of type "int | slice[Any, Any, Any] | ndarray[tuple[int], dtype[numpy.bool[builtins.bool]]]"
mitmproxy (https://github.com/mitmproxy/mitmproxy)
- mitmproxy/utils/strutils.py:125: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/io/tnetstring.py:217: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/io/tnetstring.py:224: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/coretypes/serializable.py:94: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/coretypes/serializable.py:137: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/coretypes/serializable.py:145: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/coretypes/serializable.py:151: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/coretypes/serializable.py:158: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/coretypes/serializable.py:164: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/coretypes/serializable.py:170: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/coretypes/serializable.py:176: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/coretypes/serializable.py:182: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/coretypes/serializable.py:185: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/io/compat.py:281: error: Need type annotation for "_websocket_handshakes" (hint: "_websocket_handshakes: dict[<type>, <type>] = ...") [var-annotated]
- mitmproxy/utils/vt_codes.py:10: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/net/encoding.py:127: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/coretypes/multidict.py:153: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/coretypes/multidict.py:167: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/coretypes/multidict.py:197: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/net/http/url.py:52: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/net/http/url.py:67: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/net/http/url.py:70: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/proxy/mode_specs.py:46: error: Unused "type: ignore" comment [unused-ignore]
- web/gen/web_columns.py:22: error: Item "None" of "Match[str] | None" has no attribute "group" [union-attr]
- mitmproxy/utils/asyncio_utils.py:11: error: Need type annotation for "_KEEP_ALIVE" (hint: "_KEEP_ALIVE: set[<type>] = ...") [var-annotated]
- mitmproxy/utils/asyncio_utils.py:96: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/certs.py:183: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/certs.py:190: error: Name "OpenSSL.crypto.X509" is not defined [name-defined]
- mitmproxy/certs.py:194: error: Name "OpenSSL.crypto.X509" is not defined [name-defined]
- mitmproxy/certs.py:195: error: Module has no attribute "crypto" [attr-defined]
- mitmproxy/certs.py:214: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/certs.py:222: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/certs.py:330: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/certs.py:368: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/certs.py:493: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/certs.py:679: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/certs.py:698: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/utils/debug.py:130: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/utils/debug.py:131: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/connection.py:175: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/connection.py:266: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/net/tls.py:35: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/net/tls.py:36: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/net/tls.py:289: error: Argument 1 to "add_extra_chain_cert" of "Context" has incompatible type "Certificate"; expected "X509" [arg-type]
- mitmproxy/http.py:49: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/http.py:607: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/http.py:747: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/http.py:807: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/dns.py:412: error: Argument 1 to "unpack_from_with_compression" has incompatible type "bytes | bytearray"; expected "bytes" [arg-type]
- mitmproxy/dns.py:446: error: Argument 1 to "decompress_from_record_data" has incompatible type "bytes | bytearray"; expected "bytes" [arg-type]
- mitmproxy/dns.py:449: error: Argument 5 to "ResourceRecord" has incompatible type "bytes | bytearray"; expected "bytes" [arg-type]
- examples/addons/http-modify-form.py:13: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/flowfilter.py:58: error: Redundant cast to "RegexFlag" [redundant-cast]
- mitmproxy/types.py:128: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/command.py:37: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/addons/mapremote.py:68: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/addons/dns_resolver.py:178: error: List comprehension has incompatible type List[str | int]; expected List[str] [misc]
- mitmproxy/proxy/layers/quic/_client_hello_parser.py:85: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/proxy/layers/quic/_client_hello_parser.py:87: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/addons/core.py:139: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/addons/core.py:172: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/proxy/layers/quic/_raw_layers.py:46: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/proxy/layers/quic/_raw_layers.py:47: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/proxy/layers/tls.py:570: error: Argument 1 to "dtls_parse_client_hello" has incompatible type "bytearray"; expected "bytes" [arg-type]
- mitmproxy/proxy/layers/tls.py:572: error: Argument 1 to "parse_client_hello" has incompatible type "bytearray"; expected "bytes" [arg-type]
- mitmproxy/proxy/layers/quic/_stream_layers.py:625: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/proxy/layers/http/_http_h3.py:131: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/addons/tlsconfig.py:377: error: Unused "type: ignore" comment [unused-ignore]
- examples/addons/websocket-inject-message.py:37: error: Need type annotation for "tasks" (hint: "tasks: set[<type>] = ...") [var-annotated]
- mitmproxy/tools/web/app.py:425: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/tools/web/app.py:926: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/tools/console/master.py:234: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/tools/console/keymap.py:197: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/tools/console/consoleaddons.py:620: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/tools/console/grideditor/base.py:168: error: Unused "type: ignore" comment [unused-ignore]
- mitmproxy/addons/dumper.py:334: error: Unused "type: ignore" comment [unused-ignore]
- web/gen/tflow_js.py:31: error: Item "None" of "Response | None" has no attribute "trailers" [union-attr]
- web/gen/state_js.py:23: error: Need type annotation for "si1" [var-annotated]
- web/gen/state_js.py:30: error: "ServerInstance[Any]" has no attribute "_servers" [attr-defined]
- web/gen/state_js.py:31: error: Need type annotation for "si2" [var-annotated]
- web/gen/state_js.py:33: error: Need type annotation for "si3" [var-annotated]
- web/gen/state_js.py:34: error: Need type annotation for "si4" [var-annotated]
- web/gen/state_js.py:35: error: "ServerInstance[Any]" has no attribute "_server" [attr-defined]
- web/gen/state_js.py:36: error: "ServerInstance[Any]" has no attribute "_server" [attr-defined]
+ ./mitmproxy/utils/strutils.py:107: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
+ https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
+ Please report a bug at https://github.com/python/mypy/issues
+ version: 2.5.0+dev.d50f709aea448f9db3685fb3f74a42999986a8f5
+ ./mitmproxy/utils/strutils.py:107: note: use --pdb to drop into pdb
+ Traceback (most recent call last):
+ File "", line 6, in <module>
+ sys.exit(console_entry())
+ File "/__main__.py", line 16, in console_entry
+ main()
+ File "/main.py", line 167, in main
+ res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
+ File "/main.py", line 257, in run_build
+ res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
+ File "/build.py", line 427, in build
+ result = build_inner(
+ File "/build.py", line 542, in build_inner
+ graph = dispatch(sources, manager, stdout, connect_threads)
+ File "/build.py", line 4224, in dispatch
+ process_graph(graph, manager)
+ File "/build.py", line 4692, in process_graph
+ done, still_working, results = manager.wait_for_done(graph)
+ File "/build.py", line 1480, in wait_for_done
+ process_stale_scc(graph, next_scc, self)
+ File "/build.py", line 4874, in process_stale_scc
+ mod_results |= process_stale_scc_implementation(graph, [id], manager, [meta_file])
+ File "/build.py", line 5086, in process_stale_scc_implementation
+ graph[id].type_check_second_pass(todo=todo, impl_only=True)
+ File "/build.py", line 3516, in type_check_second_pass
+ result = self.type_checker().check_second_pass(
+ File "/checker.py", line 694, in check_second_pass
+ self.check_partial(node, impl_only=impl_only)
+ File "/checker.py", line 712, in check_partial
+ self.check_partial_impl(node)
+ File "/checker.py", line 734, in check_partial_impl
+ self.visit_func_def_impl(impl)
+ File "/checker.py", line 1375, in visit_func_def_impl
+ self.check_func_item(defn, name=defn.name)
+ File "/checker.py", line 1408, in check_func_item
+ self.check_func_def(defn, typ, name, allow_empty)
+ File "/checker.py", line 1593, in check_func_def
+ self.accept(item.body)
+ File "/checker.py", line 783, in accept
+ stmt.accept(self)
+ File "/nodes.py", line 1834, in accept
+ return visitor.visit_block(self)
+ File "/checker.py", line 3378, in visit_block
+ self.accept(s)
+ File "/checker.py", line 783, in accept
+ stmt.accept(self)
+ File "/nodes.py", line 2109, in accept
+ return visitor.visit_if_stmt(self)
+ File "/checker.py", line 5482, in visit_if_stmt
+ self.accept(b)
+ File "/checker.py", line 783, in accept
+ stmt.accept(self)
+ File "/nodes.py", line 1834, in accept
+ return visitor.visit_block(self)
+ File "/checker.py", line 3378, in visit_block
+ self.accept(s)
+ File "/checker.py", line 783, in accept
+ stmt.accept(self)
+ File "/nodes.py", line 1921, in accept
+ return visitor.visit_assignment_stmt(self)
+ File "/checker.py", line 3429, in visit_assignment_stmt
+ self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None)
+ File "/checker.py", line 3591, in check_assignment
+ rvalue_type, lvalue_type = self.check_simple_assignment(
+ File "/checker.py", line 5041, in check_simple_assignment
+ rvalue_type = self.expr_checker.accept(
+ File "/checkexpr.py", line 6322, in accept
+ typ = self.accept_maybe_cache(node, type_context=type_context)
+ File "/checkexpr.py", line 6357, in accept_maybe_cache
+ typ = node.accept(self)
+ File "/nodes.py", line 2562, in accept
+ return visitor.visit_call_expr(self)
+ File "/checkexpr.py", line 509, in visit_call_expr
+ return self.visit_call_expr_inner(e, allow_none_return=allow_none_return)
+ File "/checkexpr.py", line 640, in visit_call_expr_inner
+ ret_type = self.check_call_expr_with_callee_type(
+ File "/checkexpr.py", line 1511, in check_call_expr_with_callee_type
+ ret_type, callee_type = self.check_call(
+ File "/checkexpr.py", line 1618, in check_call
+ return self.check_overload_call(
+ File "/checkexpr.py", line 2935, in check_overload_call
+ inferred_result = self.infer_overload_return_type(
+ File "/checkexpr.py", line 3111, in infer_overload_return_type
+ ret_type, infer_type = self.check_call(
+ File "/checkexpr.py", line 1607, in check_call
+ return self.check_callable_call(
+ File "/checkexpr.py", line 1863, in check_callable_call
+ arg_types = self.infer_arg_types_in_context(callee, args, arg_kinds, formal_to_actual)
+ File "/checkexpr.py", line 2106, in infer_arg_types_in_context
+ res.append(self.accept(arg, ctx))
+ File "/checkexpr.py", line 6324, in accept
+ typ = node.accept(self) # r-value type, when interpreted as a value expression
+ File "/nodes.py", line 2906, in accept
+ return visitor.visit_lambda_expr(self)
+ File "/checkexpr.py", line 5715, in visit_lambda_expr
+ self.chk.check_func_item(e, type_override=type_override)
+ File "/checker.py", line 1408, in check_func_item
+ self.check_func_def(defn, typ, name, allow_empty)
+ File "/checker.py", line 1593, in check_func_def
+ self.accept(item.body)
+ File "/checker.py", line 783, in accept
+ stmt.accept(self)
+ File "/nodes.py", line 1834, in accept
+ return visitor.visit_block(self)
+ File "/checker.py", line 3378, in visit_block
+ self.accept(s)
+ File "/checker.py", line 783, in accept
+ stmt.accept(self)
+ File "/nodes.py", line 2030, in accept
+ return visitor.visit_return_stmt(self)
+ File "/checker.py", line 5314, in visit_return_stmt
+ self.check_return_stmt(s)
+ File "/checker.py", line 5394, in check_return_stmt
+ typ = self.infer_context_dependent(s.expr, return_type, allow_none_func_call)
+ File "/checker.py", line 5328, in infer_context_dependent
+ self.expr_checker.accept(
+ File "/checkexpr.py", line 6324, in accept
+ typ = node.accept(self) # r-value type, when interpreted as a value expression
+ File "/nodes.py", line 2716, in accept
+ return visitor.visit_op_expr(self)
+ ~~~~~~~~~~~~~~~~~~~~~^^^^^^
+ File "/checkexpr.py", line 3730, in visit_op_expr
+ result, method_type = self.check_op(
+ ~~~~~~~~~~~~~^
+ method,
+ ^^^^^^^
+ ...<3 lines>...
+ allow_reverse=use_reverse is UseReverse.DEFAULT,
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ )
+ ^
+ File "/checkexpr.py", line 4438, in check_op
+ self.msg.warn_operand_was_from_union(
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
+ "Left", base_type, context=recent_context, parent_error=err
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ )
+ ^
+ File "/messages.py", line 1791, in warn_operand_was_from_union
+ self.note(
+ ~~~~~~~~~^
+ f"{side} operand is of type {format_type(original, self.options)}",
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ ...<2 lines>...
+ parent_error=parent_error,
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ )
+ ^
+ File "/messages.py", line 295, in note
+ self.report(
+ ~~~~~~~~~~~^
+ msg,
+ ^^^^
+ ...<5 lines>...
+ parent_error=parent_error,
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ )
+ ^
+ File "/messages.py", line 260, in report
+ return self.errors.report(
+ ~~~~~~~~~~~~~~~~~~^
+ context.line if context else -1,
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ ...<8 lines>...
+ parent_error=parent_error,
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ )
+ ^
+ File "/errors.py", line 657, in report
+ assert code == parent_error.code, "Must have same error code as parent"
+ ^^^^^^^^^^^^^^^^^^^^^^^^^
+ AssertionError: Must have same error code as parent
+
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When an error and its note land on different lines of a multi-line expression, a
type: ignorecomment on the error's line suppressed the error but the note still leaked, because the note's ownorigin_spandoes not include the ignored line. Reproduction (from #22271):Before:
main:3: note: Left operand is of type "b | Any"despiteSuccess: no issues found. After: no output.Changes:
add_error_infonow suppresses a note when itsparent_erroris ignored on the parent's own line(s).ErrorInfofromunsupported_operand_types) so they take part in that logic.ErrorInfo.origin_spanis normalized to a list so the parent's span can be inspected after it was already iterated elsewhere.Fixes #22271
Test plan
testIgnoredOperatorErrorDoesNotLeakNote(check-unions.test) reproduces the issue; it fails on unpatched sources and passes with this change (verified by stashing only the source files).pytest mypy/test/testcheck.py -k "check-unions": 85 passed.Prepared with AI assistance.