[ty] Fix attribute access on Callable-bounded TypeVars#24793
Draft
charliermarsh wants to merge 1 commit intomainfrom
Draft
[ty] Fix attribute access on Callable-bounded TypeVars#24793charliermarsh wants to merge 1 commit intomainfrom
charliermarsh wants to merge 1 commit intomainfrom
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 87.94%. The percentage of expected errors that received a diagnostic held steady at 83.36%. The number of fully passing files held steady at 79/133. |
Memory usage reportMemory usage unchanged ✅ |
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
unresolved-attribute |
58 | 0 | 0 |
unused-type-ignore-comment |
0 | 12 | 0 |
type-assertion-failure |
0 | 3 | 0 |
possibly-missing-attribute |
2 | 0 | 0 |
invalid-argument-type |
1 | 0 | 0 |
invalid-assignment |
1 | 0 | 0 |
| Total | 62 | 15 | 0 |
Raw diff (77 changes)
CPython (Argument Clinic) (https://github.com/python/cpython)
+ Tools/clinic/libclinic/converter.py:47:10 error[unresolved-attribute] Object of type `CConverterClassT@add_default_legacy_c_converter` has no attribute `format_unit`
+ Tools/clinic/libclinic/converter.py:48:10 error[unresolved-attribute] Object of type `CConverterClassT@add_default_legacy_c_converter` has no attribute `format_unit`
+ Tools/clinic/libclinic/converter.py:49:27 error[unresolved-attribute] Object of type `CConverterClassT@add_default_legacy_c_converter` has no attribute `format_unit`
CPython (peg_generator) (https://github.com/python/cpython)
+ Tools/peg_generator/pegen/parser.py:22:19 error[unresolved-attribute] Object of type `F@logger` has no attribute `__name__`
+ Tools/peg_generator/pegen/parser.py:42:19 error[unresolved-attribute] Object of type `F@memoize` has no attribute `__name__`
Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ tanjun/commands/message.py:315:24 error[unresolved-attribute] Object of type `_MessageCallbackSigT@MessageCommand` has no attribute `__name__`
beartype (https://github.com/beartype/beartype)
+ beartype/_util/api/standard/utilfunctools.py:308:24 error[unresolved-attribute] Object of type `BeartypeableT@beartype_functools_lru_cache & Top[(...) -> object]` has no attribute `cache_parameters`
+ beartype/_decor/_nontype/_decordescriptor.py:153:9 error[invalid-argument-type] Argument to function `beartype_func` is incorrect: Argument type `((Any, /) -> Any) | None` does not satisfy upper bound `((...) -> Any) | classmethod[Unknown, (...), Unknown] | property` of type variable `BeartypeableT`
+ beartype/_util/cache/utilcachecall.py:188:34 error[unresolved-attribute] Object of type `CallableT@callable_cached` has no attribute `__name__`
+ beartype/_util/cache/utilcachecall.py:430:34 error[unresolved-attribute] Object of type `CallableT@method_cached_arg_by_id` has no attribute `__name__`
+ beartype/_util/cache/utilcachecall.py:581:44 error[unresolved-attribute] Object of type `CallableT@property_cached` has no attribute `__name__`
boostedblob (https://github.com/hauntsaninja/boostedblob)
- boostedblob/path.py:284:20 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- boostedblob/path.py:288:20 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
core (https://github.com/home-assistant/core)
+ homeassistant/components/sonos/helpers.py:84:42 warning[possibly-missing-attribute] Attribute `soco` may be missing on object of type `_T@wrapper`
+ homeassistant/scripts/benchmark/__init__.py:56:16 error[unresolved-attribute] Object of type `_CallableT@benchmark` has no attribute `__name__`
dd-trace-py (https://github.com/DataDog/dd-trace-py)
+ ddtrace/testing/internal/logging.py:39:68 error[unresolved-attribute] Object of type `F@decorator` has no attribute `__name__`
discord.py (https://github.com/Rapptz/discord.py)
+ discord/app_commands/commands.py:465:5 error[unresolved-attribute] Unresolved attribute `__discord_app_commands_base_function__` on type `F@mark_overrideable`
+ discord/client.py:2104:23 error[unresolved-attribute] Object of type `CoroT@event` has no attribute `__name__`
+ discord/client.py:2105:71 error[unresolved-attribute] Object of type `CoroT@event` has no attribute `__name__`
+ discord/ext/commands/cog.py:268:5 error[unresolved-attribute] Unresolved attribute `__cog_special_method__` on type `FuncT@_cog_special_method`
+ discord/ext/commands/cog.py:497:24 error[unresolved-attribute] Object of type `FuncT@_get_overridden_method` has no attribute `__func__`
+ discord/ext/commands/cog.py:527:13 error[unresolved-attribute] Unresolved attribute `__cog_listener__` on type `Top[(...) -> Coroutine[Any, Any, Any]]`
+ discord/ext/commands/cog.py:528:33 error[unresolved-attribute] Object of type `Top[(...) -> Coroutine[Any, Any, Any]]` has no attribute `__name__`
+ discord/ext/commands/cog.py:530:17 error[unresolved-attribute] Object of type `Top[(...) -> Coroutine[Any, Any, Any]]` has no attribute `__cog_listener_names__`
+ discord/ext/commands/cog.py:532:17 error[unresolved-attribute] Unresolved attribute `__cog_listener_names__` on type `Top[(...) -> Coroutine[Any, Any, Any]]`
+ discord/ext/commands/help.py:248:5 error[unresolved-attribute] Unresolved attribute `__help_command_not_overridden__` on type `FuncT@_not_overridden`
+ discord/ext/tasks/__init__.py:175:49 error[unresolved-attribute] Object of type `LF@Loop` has no attribute `__qualname__`
+ discord/ext/tasks/__init__.py:238:29 error[unresolved-attribute] Object of type `LF@Loop` has no attribute `__qualname__`
+ discord/ext/tasks/__init__.py:257:25 error[unresolved-attribute] Object of type `LF@Loop` has no attribute `__qualname__`
+ discord/ext/tasks/__init__.py:306:22 error[unresolved-attribute] Object of type `LF@Loop` has no attribute `__name__`
+ discord/ext/tasks/__init__.py:553:75 error[unresolved-attribute] Object of type `LF@Loop` has no attribute `__name__`
freqtrade (https://github.com/freqtrade/freqtrade)
+ freqtrade/exchange/common.py:181:26 error[unresolved-attribute] Object of type `F@retrier` has no attribute `__name__`
hydpy (https://github.com/hydpy-dev/hydpy)
- hydpy/core/importtools.py:815:21 error[type-assertion-failure] Type `Unknown & ~Literal[0] & ~Literal[1]` is not equivalent to `Never`
- hydpy/core/importtools.py:912:13 error[type-assertion-failure] Type `Unknown & ~Literal[0] & ~Literal[1]` is not equivalent to `Never`
- hydpy/core/importtools.py:968:13 error[type-assertion-failure] Type `Unknown & ~Literal[0] & ~Literal[1]` is not equivalent to `Never`
hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
+ src/hydra_zen/third_party/beartype.py:125:9 error[invalid-assignment] Object of type `(bound method _T@validates_with_beartype.__init__() -> None) & (Overload[(o: object, /) -> None, (name: str, bases: tuple[type, ...], dict: dict[str, Any], /, **kwds: Any) -> None])` is not assignable to attribute `__init__` on type `_T@validates_with_beartype & type`
jax (https://github.com/google/jax)
+ jax/_src/api.py:2491:12 error[unresolved-attribute] Object of type `F@named_call` has no attribute `__name__`
jinja (https://github.com/pallets/jinja)
- src/jinja2/sandbox.py:111:31 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- src/jinja2/utils.py:51:42 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- src/jinja2/utils.py:68:47 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- src/jinja2/utils.py:81:46 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- src/jinja2/utils.py:93:40 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ src/jinja2/utils.py:100:23 error[unresolved-attribute] Object of type `F@internalcode` has no attribute `__code__`
meson (https://github.com/mesonbuild/meson)
+ mesonbuild/interpreterbase/baseobjects.py:92:13 error[unresolved-attribute] Unresolved attribute `meson_method` on type `TV_func@decorator`
+ mesonbuild/interpreterbase/baseobjects.py:101:13 error[unresolved-attribute] Unresolved attribute `meson_operator` on type `TV_func@decorator`
+ mesonbuild/rewriter.py:90:62 error[unresolved-attribute] Object of type `TV_func@__call__` has no attribute `__name__`
nox (https://github.com/wntrblm/nox)
+ nox/_decorators.py:54:9 error[unresolved-attribute] Object of type `T@_copy_func` has no attribute `__code__`
+ nox/_decorators.py:55:9 error[unresolved-attribute] Object of type `T@_copy_func` has no attribute `__globals__`
+ nox/_decorators.py:56:22 error[unresolved-attribute] Object of type `T@_copy_func` has no attribute `__name__`
+ nox/_decorators.py:57:17 error[unresolved-attribute] Object of type `T@_copy_func` has no attribute `__defaults__`
+ nox/_decorators.py:58:17 error[unresolved-attribute] Object of type `T@_copy_func` has no attribute `__closure__`
+ nox/_decorators.py:62:26 error[unresolved-attribute] Object of type `T@_copy_func` has no attribute `__kwdefaults__`
pandas (https://github.com/pandas-dev/pandas)
+ pandas/compat/__init__.py:48:5 error[unresolved-attribute] Unresolved attribute `__name__` on type `F@set_function_name`
+ pandas/compat/__init__.py:49:5 error[unresolved-attribute] Unresolved attribute `__qualname__` on type `F@set_function_name`
+ pandas/core/nanops.py:85:26 error[unresolved-attribute] Object of type `F@__call__` has no attribute `__name__`
+ pandas/core/nanops.py:109:32 error[unresolved-attribute] Object of type `F@__call__` has no attribute `__name__`
+ pandas/core/strings/accessor.py:132:21 error[unresolved-attribute] Object of type `F@_forbid_nonstring_types` has no attribute `__name__`
pegen (https://github.com/we-like-parsers/pegen)
+ src/pegen/parser.py:28:19 error[unresolved-attribute] Object of type `F@logger` has no attribute `__name__`
+ src/pegen/parser.py:48:19 error[unresolved-attribute] Object of type `F@memoize` has no attribute `__name__`
psycopg (https://github.com/psycopg/psycopg)
+ psycopg/psycopg/pq/_debug.py:94:38 error[unresolved-attribute] Object of type `Func@debugging` has no attribute `__name__`
pwndbg (https://github.com/pwndbg/pwndbg)
+ pwndbg/aglib/heap/ptmalloc.py:1202:74 warning[possibly-missing-attribute] Attribute `keys` may be missing on object of type `TheType@GlibcMemoryAllocator`
pydantic (https://github.com/pydantic/pydantic)
+ pydantic/v1/decorator.py:264:44 error[unresolved-attribute] Object of type `AnyCallableT@__init__` has no attribute `__name__`
schemathesis (https://github.com/schemathesis/schemathesis)
+ src/schemathesis/core/registries.py:18:21 error[unresolved-attribute] Object of type `T@Registry` has no attribute `__name__`
scipy (https://github.com/scipy/scipy)
+ scipy/_lib/doccer.py:127:38 error[unresolved-attribute] Object of type `_F@_doc` has no attribute `__name__`
+ scipy/_lib/doccer.py:162:38 error[unresolved-attribute] Object of type `_F@_doc` has no attribute `__name__`
+ scipy/_lib/doccer.py:203:38 error[unresolved-attribute] Object of type `_F@_doc` has no attribute `__name__`
setuptools (https://github.com/pypa/setuptools)
+ setuptools/config/__init__.py:24:26 error[unresolved-attribute] Object of type `Fn@_deprecation_notice` has no attribute `__name__`
spack (https://github.com/spack/spack)
- lib/spack/spack/vendor/jinja2/sandbox.py:121:31 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- lib/spack/spack/vendor/jinja2/utils.py:43:42 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- lib/spack/spack/vendor/jinja2/utils.py:60:47 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- lib/spack/spack/vendor/jinja2/utils.py:73:46 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
- lib/spack/spack/vendor/jinja2/utils.py:85:40 warning[unused-type-ignore-comment] Unused blanket `type: ignore` directive
+ lib/spack/spack/vendor/jinja2/utils.py:157:23 error[unresolved-attribute] Object of type `F@internalcode` has no attribute `__code__`
trio (https://github.com/python-trio/trio)
+ src/trio/_util.py:189:9 error[unresolved-attribute] Unresolved attribute `__name__` on type `CallT@decorator`
+ src/trio/_util.py:190:9 error[unresolved-attribute] Unresolved attribute `__qualname__` on type `CallT@decorator`
zulip (https://github.com/zulip/zulip)
+ corporate/tests/test_stripe.py:132:31 error[unresolved-attribute] Object of type `CallableT@fixture_files_for_function` has no attribute `__name__`
+ zerver/lib/test_helpers.py:476:28 error[unresolved-attribute] Object of type `UrlFuncT@instrument_url` has no attribute `__name__`
Member
Author
|
According to Codex, the Same for |
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.
When converting
type[T]into the metatype for a concreteT, we were doingSubclassOfType::try_from_instance(...). But that method only handles a subset of types: nominal types,TypedDict, etc., and falls back totype[Unknown]forCallable, allowing arbitrary attribute access.We now use
Type::to_meta_type(...), which is more general and knows how to handleCallable, etc.I'm not yet certain why we weren't using this from the start.
Closes astral-sh/ty#3303.