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

Improve CallableType join in simple cases #18406

Closed
wants to merge 4 commits into from

Conversation

hauntsaninja
Copy link
Collaborator

Fixes #17479 , although as you can see in the test case the logic still remains far from perfect

Fixes python#17479 , although as you can see in the test case the logic still
remains far from perfect

This comment has been minimized.

@hauntsaninja
Copy link
Collaborator Author

ddtrace:
fixes false positive in utils_redis.py
schema is because we have a nested dict, so inferring narrower types on the inner dicts means the outer dict becomes dict[str, object] instead of dict[str, dict[str, builtins.function]]
span_attribute_schema seems regrettable, let me see what i can do

prefect:
fixes false positive in profile.py
it's unclear to me how provisioners was working earlier, was it inferring a union? will look further

This comment has been minimized.

Copy link
Contributor

github-actions bot commented Jan 2, 2025

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

prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/cli/profile.py:178: error: Cannot call function of unknown type  [operator]
+ src/prefect/infrastructure/provisioners/__init__.py:57: error: Incompatible return value type (got "object", expected "type[Provisioner]")  [return-value]

pydantic (https://github.com/pydantic/pydantic)
+ pydantic/_internal/_std_types_schema.py:81: error: Argument 2 to <set> has incompatible type "type[Path]"; expected "type[PathLike[AnyStr_co]]"  [arg-type]
+ pydantic/_internal/_std_types_schema.py:82: error: Argument 3 to <set> has incompatible type "type[PurePath]"; expected "type[PathLike[AnyStr_co]]"  [arg-type]
+ pydantic/_internal/_std_types_schema.py:83: error: Argument 4 to <set> has incompatible type "type[PosixPath]"; expected "type[PathLike[AnyStr_co]]"  [arg-type]
+ pydantic/_internal/_std_types_schema.py:84: error: Argument 5 to <set> has incompatible type "type[PurePosixPath]"; expected "type[PathLike[AnyStr_co]]"  [arg-type]
+ pydantic/_internal/_std_types_schema.py:85: error: Argument 6 to <set> has incompatible type "type[PureWindowsPath]"; expected "type[PathLike[AnyStr_co]]"  [arg-type]

pandas (https://github.com/pandas-dev/pandas)
+ pandas/tests/io/formats/test_console.py:57: error: List item 1 has incompatible type "type[Error]"; expected "type[AttributeError]"  [list-item]

sphinx (https://github.com/sphinx-doc/sphinx)
+ sphinx/transforms/__init__.py:239:5: error: Dict entry 4 has incompatible type "str": "type[image]"; expected "str": "type[TextElement]"  [dict-item]

dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ ddtrace/internal/schema/__init__.py:43: error: Value of type "object" is not indexable  [index]
+ ddtrace/internal/schema/__init__.py:44: error: Value of type "object" is not indexable  [index]
+ ddtrace/internal/schema/__init__.py:45: error: Value of type "object" is not indexable  [index]
+ ddtrace/internal/schema/__init__.py:46: error: Value of type "object" is not indexable  [index]
+ ddtrace/internal/schema/__init__.py:47: error: Value of type "object" is not indexable  [index]
+ ddtrace/internal/schema/__init__.py:48: error: Value of type "object" is not indexable  [index]
+ ddtrace/internal/schema/__init__.py:49: error: Value of type "object" is not indexable  [index]
+ ddtrace/internal/schema/__init__.py:50: error: Value of type "object" is not indexable  [index]
+ ddtrace/_trace/utils_redis.py:35: error: Unused "type: ignore" comment  [unused-ignore]

steam.py (https://github.com/Gobot1234/steam.py)
+ steam/ext/commands/commands.py:851: error: Overloaded function implementation does not accept all possible arguments of signature 1  [misc]

pandera (https://github.com/pandera-dev/pandera)
+ tests/core/test_decorators.py:502: error: List item 0 has incompatible type "tuple[int, type[TypeError], None]"; expected "tuple[object, type[AttributeError], str | None]"  [list-item]
+ tests/core/test_decorators.py:503: error: List item 1 has incompatible type "tuple[float, type[TypeError], None]"; expected "tuple[object, type[AttributeError], str | None]"  [list-item]
+ tests/core/test_decorators.py:504: error: List item 2 has incompatible type "tuple[str, type[TypeError], None]"; expected "tuple[object, type[AttributeError], str | None]"  [list-item]
+ tests/core/test_decorators.py:505: error: List item 3 has incompatible type "tuple[list[str], type[ValueError], str]"; expected "tuple[object, type[AttributeError], str | None]"  [list-item]

ibis (https://github.com/ibis-project/ibis)
+ ibis/tests/expr/test_table.py:577: error: List item 0 has incompatible type "tuple[str, type[IbisTypeError]]"; expected "tuple[Any, type[AttributeError]]"  [list-item]
+ ibis/tests/expr/test_table.py:578: error: List item 1 has incompatible type "tuple[tuple[str, bool], type[IbisTypeError]]"; expected "tuple[Any, type[AttributeError]]"  [list-item]
+ ibis/tests/expr/test_table.py:579: error: List item 2 has incompatible type "tuple[Value, type[IbisTypeError]]"; expected "tuple[Any, type[AttributeError]]"  [list-item]

spack (https://github.com/spack/spack)
+ lib/spack/spack/test/repo.py:226: error: List item 1 has incompatible type "type[RepoPath]"; expected "type[Repo]"  [list-item]
+ lib/spack/spack/test/repo.py:266: error: List item 1 has incompatible type "type[RepoPath]"; expected "type[Repo]"  [list-item]
+ lib/spack/spack/test/repo.py:272: error: List item 1 has incompatible type "type[RepoPath]"; expected "type[Repo]"  [list-item]
+ lib/spack/spack/test/repo.py:282: error: List item 1 has incompatible type "type[RepoPath]"; expected "type[Repo]"  [list-item]

poetry (https://github.com/python-poetry/poetry)
+ tests/utils/test_isolated_build.py:62: error: List item 0 has incompatible type "tuple[set[str], type[IncompatibleConstraintsError]]"; expected "tuple[set[str], type[SolverProblemError]]"  [list-item]

scikit-learn (https://github.com/scikit-learn/scikit-learn)
+ sklearn/feature_extraction/tests/test_text.py:1406: error: List item 0 has incompatible type "tuple[str, type[FileNotFoundError], str]"; expected "tuple[str, type[AttributeError], str]"  [list-item]
+ sklearn/model_selection/tests/test_classification_threshold.py:204: error: List item 0 has incompatible type "tuple[dict[str, object], type[ValueError], str]"; expected "tuple[object, type[NotFittedError], str]"  [list-item]
+ sklearn/model_selection/tests/test_classification_threshold.py:209: error: List item 1 has incompatible type "tuple[dict[str, int], type[ValueError], str]"; expected "tuple[object, type[NotFittedError], str]"  [list-item]
+ sklearn/feature_selection/tests/test_rfe.py:485: error: List item 0 has incompatible type "tuple[str, type[ValueError]]"; expected "tuple[object, type[AttributeError]]"  [list-item]

@hauntsaninja hauntsaninja deleted the function-join branch January 3, 2025 09:28
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.

(🐞) overlapping Callables are incorrectly joined into builtins.function
1 participant