Skip to content
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

don't add redundant types to unions to prevent unnecessary unknown/any errors #447

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

DetachHead
Copy link
Owner

fixes #71

This comment has been minimized.

This comment has been minimized.

@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch from a1c2a7f to ea424af Compare June 25, 2024 12:56
@DetachHead DetachHead changed the title don't add narrowed type from if statement to union after the statement is over because it has no effect other than creating unknown/any errors unnecessarily don't add redundant types to unions to prevent unnecessary unknown/any errors Jun 25, 2024

This comment has been minimized.

@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch 2 times, most recently from d519876 to 4289d78 Compare June 29, 2024 03:06

This comment has been minimized.

@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch from 4289d78 to d779f74 Compare June 29, 2024 04:53

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch from e95fd17 to 3a9ab80 Compare June 30, 2024 04:21

This comment has been minimized.

@DetachHead DetachHead force-pushed the fix-unknown-error-after-narrowing branch from 3a9ab80 to 43d9ac5 Compare June 30, 2024 06:32
Copy link
Contributor

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

pyp (https://github.com/hauntsaninja/pyp)
-   /tmp/mypy_primer/projects/pyp/pyp.py:39:15 - error: Argument type is partially unknown
+   /tmp/mypy_primer/projects/pyp/pyp.py:39:15 - error: Argument type is unknown
-     Argument corresponds to parameter "values" in function "print"
+     Argument corresponds to parameter "values" in function "print" (reportUnknownArgumentType)
-     Argument type is "Unknown | str" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/pyp/tests/test_pyp.py:50:25 - error: "old_stdin" is possibly unbound (reportPossiblyUnboundVariable)
+   /tmp/mypy_primer/projects/pyp/tests/test_pyp.py:50:25 - error: "old_stdin" is unbound (reportUnboundVariable)

alectryon (https://github.com/cpitclaudel/alectryon)
-     Type of "alectryon_state" is "(document: Unknown) -> (AlectryonState | Unknown)" (reportUnknownVariableType)
+     Type of "alectryon_state" is "(document: Unknown) -> Unknown" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:155:5 - error: Type of "embedded_assets" is partially unknown
+   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:155:5 - error: Type of "embedded_assets" is Any (reportAny)
-     Type of "embedded_assets" is "Any | list[Unknown]" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:155:23 - error: Type of "embedded_assets" is partially unknown
+   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:155:23 - error: Type of "embedded_assets" is Any (reportAny)
-     Type of "embedded_assets" is "Any | list[Unknown]" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:670:37 - error: Type of "point" is partially unknown
+   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:670:37 - error: Type of "point" is unknown (reportUnknownMemberType)
-     Type of "point" is "Unknown | int" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:670:37 - error: Argument type is partially unknown
+   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:670:37 - error: Argument type is unknown
-     Argument corresponds to parameter "args" in function "format"
+     Argument corresponds to parameter "args" in function "format" (reportUnknownArgumentType)
-     Argument type is "Unknown | int" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:881:5 - error: Type of "fname" is partially unknown
+   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:881:5 - error: Type of "fname" is unknown (reportUnknownVariableType)
-     Type of "fname" is "Unknown | str" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:881:30 - error: Argument type is partially unknown
+   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:881:30 - error: Argument type is unknown
-     Argument corresponds to parameter "p" in function "basename"
+     Argument corresponds to parameter "p" in function "basename" (reportUnknownArgumentType)
-     Argument type is "Unknown | Literal['-']" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:902:13 - error: Type of "refpath" is partially unknown
+   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:902:13 - error: Type of "refpath" is unknown (reportUnknownVariableType)
-     Type of "refpath" is "Unknown | Literal['-']" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:903:55 - error: Argument type is partially unknown
+   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:903:55 - error: Argument type is unknown
-     Argument corresponds to parameter "p" in function "dirname"
+     Argument corresponds to parameter "p" in function "dirname" (reportUnknownArgumentType)
-     Argument type is "Unknown | str" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:903:71 - error: Argument type is partially unknown
+   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:903:71 - error: Argument type is unknown
-     Argument corresponds to parameter "path" in function "abspath"
+     Argument corresponds to parameter "path" in function "abspath" (reportUnknownArgumentType)
-     Argument type is "Unknown | Literal['-']" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:905:17 - error: No overloads for "abspath" match the provided arguments (reportCallIssue)
-   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:905:33 - error: Argument of type "Unknown | str | ExitCode | list[Unknown] | None" cannot be assigned to parameter "path" of type "AnyStr@abspath" in function "abspath"
-     Type "Unknown | str | ExitCode | list[Unknown] | None" is incompatible with constrained type variable "AnyStr" (reportArgumentType)
+   /tmp/mypy_primer/projects/alectryon/alectryon/cli.py:905:33 - error: Argument type is unknown
+     Argument corresponds to parameter "path" in function "abspath" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:56:26 - error: Argument type is partially unknown
+   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:56:26 - error: Argument type is unknown
-     Argument corresponds to parameter "object" in function "__new__"
+     Argument corresponds to parameter "object" in function "__new__" (reportUnknownArgumentType)
-     Argument type is "str | Unknown" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:274:9 - error: Return type, "list[Unknown]", is partially unknown (reportUnknownParameterType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:275:12 - error: Type of "_bol_offsets" is partially unknown
-     Type of "_bol_offsets" is "list[Unknown] | None" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:277:13 - error: Type of "matches" is unknown (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:277:23 - error: No overloads for "finditer" match the provided arguments (reportCallIssue)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:277:35 - error: Argument of type "Literal['^', b"^"]" cannot be assigned to parameter "pattern" of type "str | Pattern[str]" in function "finditer" (reportArgumentType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:277:40 - error: Type of "contents" is partially unknown
-     Type of "contents" is "str | Unknown" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:278:13 - error: Type of "_bol_offsets" is partially unknown
-     Type of "_bol_offsets" is "list[Unknown]" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:278:34 - error: Type of "start" is unknown (reportUnknownMemberType)
+   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:277:40 - error: Type of "contents" is unknown (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:278:48 - error: Type of "m" is unknown (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:279:16 - error: Type of "_bol_offsets" is partially unknown
+   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:277:40 - error: Argument type is unknown
+     Argument corresponds to parameter "string" in function "finditer" (reportUnknownArgumentType)
-     Type of "_bol_offsets" is "list[Unknown]" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:279:16 - error: Return type, "list[Unknown]", is partially unknown (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:283:37 - error: Type of "bol_offsets" is partially unknown
-     Type of "bol_offsets" is "list[Unknown]" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:283:37 - error: Argument type is partially unknown
-     Argument corresponds to parameter "a" in function "bisect_right"
-     Argument type is "list[Unknown]" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:284:9 - error: Type of "bol" is unknown (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:284:15 - error: Type of "bol_offsets" is partially unknown
-     Type of "bol_offsets" is "list[Unknown]" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:288:16 - error: Type of "bol_offsets" is partially unknown
-     Type of "bol_offsets" is "list[Unknown]" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/core.py:288:16 - error: Return type is unknown (reportUnknownVariableType)
-     Type of "validate_style" is "(name: Unknown) -> (str | Unknown)" (reportUnknownVariableType)
+     Type of "validate_style" is "(name: Unknown) -> Unknown" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/docutils.py:149:30 - error: Argument type is partially unknown
+   /tmp/mypy_primer/projects/alectryon/alectryon/docutils.py:149:30 - error: Argument type is Any
-     Argument corresponds to parameter "args" in function "format"
+     Argument corresponds to parameter "args" in function "format" (reportAny)
-     Argument type is "Any | Unknown" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/docutils.py:181:5 - error: Return type, "AlectryonState | Unknown", is partially unknown (reportUnknownParameterType)
+   /tmp/mypy_primer/projects/alectryon/alectryon/docutils.py:181:5 - error: Return type is unknown (reportUnknownParameterType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/docutils.py:185:12 - error: Return type, "AlectryonState | Unknown", is partially unknown (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/alectryon/alectryon/docutils.py:185:12 - error: Return type is unknown (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/alectryon/alectryon/docutils.py:311:9 - error: Type of "state" is Any (reportAny)
-   /tmp/mypy_primer/projects/alectryon/alectryon/docutils.py:312:39 - error: Type of "transforms_executed" is partially unknown
+   /tmp/mypy_primer/projects/alectryon/alectryon/docutils.py:312:39 - error: Type of "transforms_executed" is Any (reportAny)
-     Type of "transforms_executed" is "set[Unknown] | Any" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/alectryon/alectryon/docutils.py:313:13 - error: Type of "transforms_executed" is partially unknown
+   /tmp/mypy_primer/projects/alectryon/alectryon/docutils.py:313:13 - error: Type of "transforms_executed" is Any (reportAny)
-     Type of "transforms_executed" is "set[Unknown] | Any" (reportUnknownMemberType)

... (truncated 269 lines) ...

pyinstrument (https://github.com/joerick/pyinstrument)
+   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/__main__.py:304:73 - error: Argument type is Any
+     Argument corresponds to parameter "output_file" in function "create_renderer" (reportAny)
+   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/__main__.py:309:76 - error: Argument type is Any
+     Argument corresponds to parameter "file_obj" in function "file_is_a_tty" (reportAny)
-   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/__main__.py:378:9 - error: Result of call expression is of type "int | Any" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/__main__.py:380:13 - error: Result of call expression is of type "Any | None" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/__main__.py:373:95 - error: Argument type is Any
+     Argument corresponds to parameter "file_obj" in function "file_is_a_tty" (reportAny)
+   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/__main__.py:378:9 - error: Type of "write" is Any (reportAny)
+   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/__main__.py:380:13 - error: Type of "close" is Any (reportAny)
-   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/middleware.py:50:31 - error: Argument type is unknown
-     Argument corresponds to parameter "request" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/stack_sampler.py:65:13 - error: Result of call expression is of type "Token[object | None]" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/stack_sampler.py:65:13 - error: Result of call expression is of type "Token[object]" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/stack_sampler.py:86:13 - error: Result of call expression is of type "Token[object | None]" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/stack_sampler.py:86:13 - error: Result of call expression is of type "Token[object]" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/stack_sampler.py:160:12 - error: Type of "stack_sampler" is Any (reportAny)
+   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/stack_sampler.py:160:12 - error: Return type is Any (reportAny)
+   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/low_level/stat_profile_python.py:105:9 - error: Type of "frame_info" is Any (reportAny)
+   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/low_level/stat_profile_python.py:108:9 - error: Type of "frame_info" is Any (reportAny)
+   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/low_level/stat_profile_python.py:110:12 - error: Return type is Any (reportAny)
-   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/magic/magic.py:115:13 - error: Type of "async_mode" is partially unknown
+   /tmp/mypy_primer/projects/pyinstrument/pyinstrument/magic/magic.py:115:13 - error: Type of "async_mode" is unknown (reportUnknownMemberType)
-     Type of "async_mode" is "Unknown | Literal['disabled']" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/pyinstrument/test/low_level/test_context.py:39:5 - error: Result of call expression is of type "Token[object | None]" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/pyinstrument/test/low_level/test_context.py:39:5 - error: Result of call expression is of type "Token[object]" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
-   /tmp/mypy_primer/projects/pyinstrument/test/low_level/test_context.py:40:5 - error: Result of call expression is of type "Token[object | None]" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
+   /tmp/mypy_primer/projects/pyinstrument/test/low_level/test_context.py:40:5 - error: Result of call expression is of type "Token[object]" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
- 1064 errors, 0 warnings, 0 notes
+ 1071 errors, 0 warnings, 0 notes

pandera (https://github.com/pandera-dev/pandera)
+   /tmp/mypy_primer/projects/pandera/pandera/decorators.py:513:39 - error: Argument type is unknown
+     Argument corresponds to parameter "schema" in function "check_output" (reportUnknownArgumentType)
+   /tmp/mypy_primer/projects/pandera/pandera/decorators.py:513:51 - error: Argument type is unknown
+     Argument corresponds to parameter "obj_getter" in function "check_output" (reportUnknownArgumentType)
-     Type of "arg" is "Unknown | Any | Type[Unknown] | None" (reportUnknownMemberType)
+     Type of "arg" is "Unknown | Any | None" (reportUnknownMemberType)
-     Type of "arg" is "Unknown | Any | Type[Unknown] | None" (reportUnknownMemberType)
+     Type of "arg" is "Unknown | Any | None" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/pandera/pandera/utils.py:16:24 - error: "_doc" is possibly unbound (reportPossiblyUnboundVariable)
-     Type of "data_types" is "tuple[Unknown | Any]" (reportUnknownVariableType)
+     Type of "data_types" is "tuple[Unknown]" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/pandera/pandera/api/extensions.py:75:13 - error: Type of "dt" is partially unknown
+   /tmp/mypy_primer/projects/pandera/pandera/api/extensions.py:75:13 - error: Type of "dt" is unknown (reportUnknownVariableType)
-     Type of "dt" is "Unknown | Any" (reportUnknownVariableType)
-     Type of "args_dict" is "dict[str, Unknown]" (reportUnknownVariableType)
+     Type of "args_dict" is "dict[Unknown | str, Unknown]" (reportUnknownVariableType)
-     Argument type is "zip[tuple[str, Unknown]]" (reportUnknownArgumentType)
+     Argument type is "zip[tuple[Unknown, Unknown]]" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/pandera/pandera/api/extensions.py:129:37 - error: Argument type is partially unknown
+   /tmp/mypy_primer/projects/pandera/pandera/api/extensions.py:129:37 - error: Argument type is unknown
-     Argument corresponds to parameter "iter1" in function "__new__"
+     Argument corresponds to parameter "iter1" in function "__new__" (reportUnknownArgumentType)
-     Argument type is "Unknown | list[str]" (reportUnknownArgumentType)
-     Type of "get" is "Overload[(key: str, /) -> (Unknown | None), (key: str, default: Unknown, /) -> Unknown, (key: str, default: _T@get, /) -> (Unknown | _T@get)]" (reportUnknownMemberType)
+     Type of "get" is "Overload[(key: Unknown | str, /) -> (Unknown | None), (key: Unknown | str, default: Unknown, /) -> Unknown, (key: Unknown | str, default: _T@get, /) -> (Unknown | _T@get)]" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/pandera/pandera/api/extensions.py:200:36 - error: "ps" is possibly unbound (reportPossiblyUnboundVariable)
-   /tmp/mypy_primer/projects/pandera/pandera/api/extensions.py:208:35 - error: "ps" is possibly unbound (reportPossiblyUnboundVariable)
-   /tmp/mypy_primer/projects/pandera/pandera/api/extensions.py:214:40 - error: Argument type is partially unknown
+   /tmp/mypy_primer/projects/pandera/pandera/api/extensions.py:214:40 - error: Argument type is unknown
-     Argument corresponds to parameter "args" in function "format"
+     Argument corresponds to parameter "args" in function "format" (reportUnknownArgumentType)
-     Argument type is "Unknown | type" (reportUnknownArgumentType)
+   /tmp/mypy_primer/projects/pandera/pandera/api/extensions.py:291:52 - error: Type of "k" is unknown (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/pandera/pandera/api/base/model_components.py:142:37 - error: Argument type is Any
+     Argument corresponds to parameter "name" in function "__init__" (reportAny)
+   /tmp/mypy_primer/projects/pandera/pandera/api/base/model_components.py:163:38 - error: Argument type is Any
+     Argument corresponds to parameter "name" in function "__init__" (reportAny)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/components.py:195:37 - error: Type of parameter "_handler" is partially unknown
+   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/components.py:195:37 - error: Type of parameter "_handler" is unknown (reportUnknownParameterType)
-     Parameter type is "Unknown | Unbound" (reportUnknownParameterType)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/components.py:195:37 - error: "_handler" is possibly unbound (reportPossiblyUnboundVariable)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/components.py:195:47 - error: "GetCoreSchemaHandler" is possibly unbound (reportPossiblyUnboundVariable)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/components.py:196:14 - error: "core_schema" is possibly unbound (reportPossiblyUnboundVariable)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/components.py:197:20 - error: "core_schema" is possibly unbound (reportPossiblyUnboundVariable)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:445:20 - error: "core_schema" is possibly unbound (reportPossiblyUnboundVariable)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:999:23 - error: Type of "index" is partially unknown
+   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:999:23 - error: Type of "index" is unknown (reportUnknownMemberType)
-     Type of "index" is "Unknown | MultiIndex" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1133:31 - error: Type of "index" is partially unknown
+   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1133:31 - error: Type of "index" is unknown (reportUnknownMemberType)
-     Type of "index" is "Unknown | MultiIndex" (reportUnknownMemberType)
-     Type of "new_index" is "MultiIndex | Unknown | None" (reportUnknownVariableType)
+     Type of "new_index" is "Unknown | None" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1145:45 - error: Type of "index" is partially unknown
+   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1145:45 - error: Type of "index" is unknown (reportUnknownMemberType)
-     Type of "index" is "MultiIndex | Index | Unknown" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1146:18 - error: Type of "index" is partially unknown
+   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1146:18 - error: Type of "index" is unknown (reportUnknownMemberType)
-     Type of "index" is "MultiIndex | Unknown" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1146:18 - error: Type of "remove_columns" is partially unknown
+   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1146:18 - error: Type of "remove_columns" is unknown (reportUnknownMemberType)
-     Type of "remove_columns" is "((cols_to_remove: List[str]) -> MultiIndex) | Unknown" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1146:50 - error: Argument type is partially unknown
-     Argument corresponds to parameter "cols_to_remove" in function "remove_columns"
-     Argument type is "Unknown | list[Any] | list[str]" (reportUnknownArgumentType)
-     Type of "new_index" is "Index | MultiIndex | Unknown | None" (reportUnknownVariableType)
+     Type of "new_index" is "Index | Unknown | None" (reportUnknownVariableType)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1153:27 - error: Type of "columns" is partially unknown
+   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1153:27 - error: Type of "columns" is unknown (reportUnknownMemberType)
-     Type of "columns" is "Dict[Any, Any] | Unknown" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1153:27 - error: Type of "dtype" is partially unknown
+   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1153:27 - error: Type of "dtype" is unknown (reportUnknownMemberType)
-     Type of "dtype" is "Any | Unknown" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1153:27 - error: Argument type is partially unknown
+   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1153:27 - error: Argument type is unknown
-     Argument corresponds to parameter "dtype" in function "__init__"
+     Argument corresponds to parameter "dtype" in function "__init__" (reportUnknownArgumentType)
-     Argument type is "Any | Unknown" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1153:50 - error: Type of "columns" is partially unknown
+   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1153:50 - error: Type of "columns" is unknown (reportUnknownMemberType)
-     Type of "columns" is "Dict[Any, Any] | Unknown" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1153:50 - error: Argument type is partially unknown
+   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1153:50 - error: Argument type is unknown
-     Argument corresponds to parameter "iterable" in function "__init__"
+     Argument corresponds to parameter "iterable" in function "__init__" (reportUnknownArgumentType)
-     Argument type is "Dict[Any, Any] | Unknown" (reportUnknownArgumentType)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1154:28 - error: Type of "columns" is partially unknown
+   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1154:28 - error: Type of "columns" is unknown (reportUnknownMemberType)
-     Type of "columns" is "Dict[Any, Any] | Unknown" (reportUnknownMemberType)
-   /tmp/mypy_primer/projects/pandera/pandera/api/dataframe/container.py:1154:28 - error: Type of "checks" is partially unknown

... (truncated 1068 lines) ...

pydantic (https://github.com/samuelcolvin/pydantic)
-     Type of "Field" is "(default: Any = PydanticUndefined, *, default_factory: (() -> Any) | None = _Unset, alias: str | None = _Unset, alias_priority: int | None = _Unset, validation_alias: str | AliasPath | AliasChoices | None = _Unset, serialization_alias: str | None = _Unset, title: str | None = _Unset, field_title_generator: ((str, FieldInfo) -> str) | None = _Unset, description: str | None = _Unset, examples: list[Any] | None = _Unset, exclude: bool | None = _Unset, discriminator: str | Discriminator | None = _Unset, deprecated: deprecated | str | bool | None = _Unset, json_schema_extra: Dict[str, int | float | str | bool | List[JsonValue] | JsonDict | None] | ((Dict[str, int | float | str | bool | List[JsonValue] | JsonDict | None]) -> None) | None = _Unset, frozen: bool | None = _Unset, validate_default: bool | None = _Unset, repr: bool = _Unset, init: bool | None = _Unset, init_var: bool | None = _Unset, kw_only: bool | None = _Unset, pattern: str | Pattern[str] | None = _Unset, strict: bool | None = _Unset, coerce_numbers_to_str: bool | None = _Unset, gt: Unknown | None = _Unset, ge: Unknown | None = _Unset, lt: Unknown | None = _Unset, le: Unknown | None = _Unset, multiple_of: float | None = _Unset, allow_inf_nan: bool | None = _Unset, max_digits: int | None = _Unset, decimal_places: int | None = _Unset, min_length: int | None = _Unset, max_length: int | None = _Unset, union_mode: Literal['smart', 'left_to_right'] = _Unset, fail_fast: bool | None = _Unset, **extra: **_EmptyKwargs) -> Any" (reportUnknownVariableType)
+     Type of "Field" is "(default: Any = PydanticUndefined, *, default_factory: (() -> Any) | None = _Unset, alias: str | None = _Unset, alias_priority: int | None = _Unset, validation_alias: str | AliasPath | AliasChoices | None = _Unset, serialization_alias: str | None = _Unset, title: str | None = _Unset, field_title_generator: ((str, FieldInfo) -> str) | None = _Unset, description: str | None = _Unset, examples: list[Any] | None = _Unset, exclude: bool | None = _Unset, discriminator: str | Discriminator | None = _Unset, deprecated: deprecated | str | bool | None = _Unset, json_schema_extra: Dict[str, int | float | str | bool | List[JsonValue] | JsonDict | None] | ((Dict[str, int | float | str | bool | List[JsonValue] | JsonDict | None]) -> None) | None = _Unset, frozen: bool | None = _Unset, validate_default: bool | None = _Unset, repr: bool = _Unset, init: bool | None = _Unset, init_var: bool | None = _Unset, kw_only: bool | None = _Unset, pattern: str | Pattern[str] | None = _Unset, strict: bool | None = _Unset, coerce_numbers_to_str: bool | None = _Unset, gt: Unknown = _Unset, ge: Unknown = _Unset, lt: Unknown = _Unset, le: Unknown = _Unset, multiple_of: float | None = _Unset, allow_inf_nan: bool | None = _Unset, max_digits: int | None = _Unset, decimal_places: int | None = _Unset, min_length: int | None = _Unset, max_length: int | None = _Unset, union_mode: Literal['smart', 'left_to_right'] = _Unset, fail_fast: bool | None = _Unset, **extra: **_EmptyKwargs) -> Any" (reportUnknownVariableType)
+   /tmp/mypy_primer/projects/pydantic/pydantic/aliases.py:120:16 - error: Return type is Any (reportAny)
-     Type of "Field" is "(default: Any = PydanticUndefined, *, default_factory: (() -> Any) | None = _Unset, alias: str | None = _Unset, alias_priority: int | None = _Unset, validation_alias: str | AliasPath | AliasChoices | None = _Unset, serialization_alias: str | None = _Unset, title: str | None = _Unset, field_title_generator: ((str, FieldInfo) -> str) | None = _Unset, description: str | None = _Unset, examples: list[Any] | None = _Unset, exclude: bool | None = _Unset, discriminator: str | Discriminator | None = _Unset, deprecated: deprecated | str | bool | None = _Unset, json_schema_extra: Dict[str, int | float | str | bool | List[JsonValue] | JsonDict | None] | ((Dict[str, int | float | str | bool | List[JsonValue] | JsonDict | None]) -> None) | None = _Unset, frozen: bool | None = _Unset, validate_default: bool | None = _Unset, repr: bool = _Unset, init: bool | None = _Unset, init_var: bool | None = _Unset, kw_only: bool | None = _Unset, pattern: str | Pattern[str] | None = _Unset, strict: bool | None = _Unset, coerce_numbers_to_str: bool | None = _Unset, gt: Unknown | None = _Unset, ge: Unknown | None = _Unset, lt: Unknown | None = _Unset, le: Unknown | None = _Unset, multiple_of: float | None = _Unset, allow_inf_nan: bool | None = _Unset, max_digits: int | None = _Unset, decimal_places: int | None = _Unset, min_length: int | None = _Unset, max_length: int | None = _Unset, union_mode: Literal['smart', 'left_to_right'] = _Unset, fail_fast: bool | None = _Unset, **extra: **_EmptyKwargs) -> Any" (reportUnknownVariableType)

... (truncated 1194 lines) ...```

@DetachHead DetachHead marked this pull request as draft June 30, 2024 10:11
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.

isinstance check incorrectly changes type to include list[Any] outside of the if statement
1 participant