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

Fixed a few places where union order resulted in different type evalu… #6306

Merged
merged 2 commits into from
Nov 3, 2023

Conversation

erictraut
Copy link
Collaborator

…ation behaviors. This addresses #6302.

Copy link
Contributor

github-actions bot commented Nov 2, 2023

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

spack (https://github.com/spack/spack)
-   /tmp/mypy_primer/projects/spack/lib/spack/spack/mirror.py:267:16 - error: Expression of type "Unknown | str | None" cannot be assigned to return type "List[Unknown] | None" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/spack/lib/spack/spack/mirror.py:267:16 - error: Expression of type "str | Unknown | None" cannot be assigned to return type "List[Unknown] | None" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/spack/lib/spack/spack/cmd/verify.py:81:17 - error: Operator "+=" not supported for types "Unknown | list[Unknown]" and "list[Spec] | list[Unknown] | Any | None"
+   /tmp/mypy_primer/projects/spack/lib/spack/spack/cmd/verify.py:81:17 - error: Operator "+=" not supported for types "Unknown | list[Unknown]" and "list[Unknown] | list[Spec] | Any | None"
-   /tmp/mypy_primer/projects/spack/lib/spack/spack/util/compression.py:303:37 - error: Argument of type "str | Unknown | LiteralString | None" cannot be assigned to parameter "path_or_url" of type "str" in function "allowed_archive"
+   /tmp/mypy_primer/projects/spack/lib/spack/spack/util/compression.py:303:37 - error: Argument of type "LiteralString | str | Unknown | None" cannot be assigned to parameter "path_or_url" of type "str" in function "allowed_archive"
-     Type "str | Unknown | LiteralString | None" cannot be assigned to type "str"
+     Type "LiteralString | str | Unknown | None" cannot be assigned to type "str"

steam.py (https://github.com/Gobot1234/steam.py)
-     Type of "upper" is "Unknown | Any" (reportUnknownMemberType)
+     Type of "upper" is "Any | Unknown" (reportUnknownMemberType)
-     Type of "strip" is "Unknown | ((__chars: str | None = None, /) -> str) | Any" (reportUnknownMemberType)
+     Type of "strip" is "((__chars: str | None = None, /) -> str) | Any | Unknown" (reportUnknownMemberType)
-     Type of "message" is "Unknown | str | Any" (reportUnknownMemberType)
+     Type of "message" is "str | Any | Unknown" (reportUnknownMemberType)
-     Type of "message" is "Unknown | str | Any" (reportUnknownMemberType)
+     Type of "message" is "str | Any | Unknown" (reportUnknownMemberType)
-     Type of "message" is "Unknown | str | Any" (reportUnknownMemberType)
+     Type of "message" is "str | Any | Unknown" (reportUnknownMemberType)
-     Type of "message" is "Unknown | str | Any" (reportUnknownMemberType)
+     Type of "message" is "str | Any | Unknown" (reportUnknownMemberType)

dd-trace-py (https://github.com/DataDog/dd-trace-py)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/appsec/_utils.py:55:35 - error: Argument of type "Unknown | str | bytes | list[Unknown]" cannot be assigned to parameter "s" of type "str | bytes | bytearray" in function "loads" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/appsec/_utils.py:55:35 - error: Argument of type "str | Unknown | bytes | list[Unknown]" cannot be assigned to parameter "s" of type "str | bytes | bytearray" in function "loads" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/appsec/_utils.py:57:40 - error: Argument of type "Unknown | str | bytes | list[Unknown]" cannot be assigned to parameter "xml_input" of type "str | ReadableBuffer | SupportsRead[bytes] | GeneratorType[ReadableBuffer, Any, Any]" in function "parse" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/appsec/_utils.py:57:40 - error: Argument of type "str | Unknown | bytes | list[Unknown]" cannot be assigned to parameter "xml_input" of type "str | ReadableBuffer | SupportsRead[bytes] | GeneratorType[ReadableBuffer, Any, Any]" in function "parse" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_psaix.py:515:12 - error: Operator "in" not supported for types "Literal['no such process']" and "str | bytes"
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_psaix.py:515:12 - error: Operator "in" not supported for types "Literal['no such process']" and "bytes | str"
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1342:28 - error: Argument of type "Unknown | str | object" cannot be assigned to parameter "__x" of type "ConvertibleToInt" in function "__new__" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1342:28 - error: Argument of type "str | Unknown | object" cannot be assigned to parameter "__x" of type "ConvertibleToInt" in function "__new__" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1370:23 - error: Operator "*" not supported for types "float" and "int | Unknown | str | object"
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1370:23 - error: Operator "*" not supported for types "float" and "int | str | Unknown | object"
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1374:23 - error: Argument of type "Unknown | str | object" cannot be assigned to parameter "__x" of type "ConvertibleToInt" in function "__new__" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1374:23 - error: Argument of type "str | Unknown | object" cannot be assigned to parameter "__x" of type "ConvertibleToInt" in function "__new__" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1402:28 - error: Operator "/" not supported for types "int | Unknown | str | object" and "int | Unknown | str | object"
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1402:28 - error: Operator "/" not supported for types "int | str | Unknown | object" and "int | str | Unknown | object"
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:707:24 - error: Argument of type "Unknown | str | object" cannot be assigned to parameter "__x" of type "ConvertibleToInt" in function "__new__" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:707:24 - error: Argument of type "str | Unknown | object" cannot be assigned to parameter "__x" of type "ConvertibleToInt" in function "__new__" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:708:24 - error: Argument of type "Unknown | str | object" cannot be assigned to parameter "__x" of type "ConvertibleToInt" in function "__new__" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:708:24 - error: Argument of type "str | Unknown | object" cannot be assigned to parameter "__x" of type "ConvertibleToInt" in function "__new__" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:709:24 - error: Argument of type "Unknown | str | object" cannot be assigned to parameter "__x" of type "ConvertibleToInt" in function "__new__" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:709:24 - error: Argument of type "str | Unknown | object" cannot be assigned to parameter "__x" of type "ConvertibleToInt" in function "__new__" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1214:29 - error: Argument of type "Unknown | str | object" cannot be assigned to parameter "__x" of type "ConvertibleToFloat" in function "__new__" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1214:29 - error: Argument of type "str | Unknown | object" cannot be assigned to parameter "__x" of type "ConvertibleToFloat" in function "__new__" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1236:30 - error: Argument of type "Unknown | str | object" cannot be assigned to parameter "__x" of type "ConvertibleToFloat" in function "__new__" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1236:30 - error: Argument of type "str | Unknown | object" cannot be assigned to parameter "__x" of type "ConvertibleToFloat" in function "__new__" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1241:34 - error: Argument of type "Unknown | str | object" cannot be assigned to parameter "__x" of type "ConvertibleToFloat" in function "__new__" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1241:34 - error: Argument of type "str | Unknown | object" cannot be assigned to parameter "__x" of type "ConvertibleToFloat" in function "__new__" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1255:33 - error: Argument of type "Unknown | str | object" cannot be assigned to parameter "__x" of type "ConvertibleToFloat" in function "__new__" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1255:33 - error: Argument of type "str | Unknown | object" cannot be assigned to parameter "__x" of type "ConvertibleToFloat" in function "__new__" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1314:27 - error: Argument of type "Unknown | str | object" cannot be assigned to parameter "__x" of type "ConvertibleToInt" in function "__new__" (reportGeneralTypeIssues)
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pslinux.py:1314:27 - error: Argument of type "str | Unknown | object" cannot be assigned to parameter "__x" of type "ConvertibleToInt" in function "__new__" (reportGeneralTypeIssues)
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pssunos.py:621:16 - error: Operator "in" not supported for types "Literal['permission denied']" and "str | bytes"
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pssunos.py:621:16 - error: Operator "in" not supported for types "Literal['permission denied']" and "bytes | str"
-   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pssunos.py:623:16 - error: Operator "in" not supported for types "Literal['no such process']" and "str | bytes"
+   /tmp/mypy_primer/projects/dd-trace-py/ddtrace/vendor/psutil/_pssunos.py:623:16 - error: Operator "in" not supported for types "Literal['no such process']" and "bytes | str"

@erictraut erictraut merged commit 2285641 into main Nov 3, 2023
12 checks passed
@erictraut erictraut deleted the issue6302 branch November 3, 2023 03:02
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.

1 participant