Skip to content

Missing argument (cls) error when classmethod is mixed with other decorators #1787

@AA-Turner

Description

@AA-Turner

Summary

I couldn't find an existing issue for this. Error is new in alpha 32, no problems reported in alpha 31.

error[missing-argument]: No argument provided for required parameter `cls`
   --> tests\test_intl\test_intl.py:880:10
    |
879 |     # see: https://github.com/pytest-dev/pytest/issues/363
880 |     with pytest.MonkeyPatch.context() as mock:
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
881 |         clock: _MockClock
882 |         if os.name == 'posix':
    |
info: Union variant `(cls) -> _GeneratorContextManager[Unknown, None, None]` is incompatible with this call site
info: Attempted to call union type `((cls) -> _GeneratorContextManager[Unknown, None, None]) | ((cls) -> _GeneratorContextManager[Unknown, None, None])`
info: rule `missing-argument` is enabled by default

Minimal reproducer (playground):

from collections.abc import Generator
from contextlib import contextmanager

class Spam:
    @contextmanager
    @classmethod
    def context(cls) -> Generator[None]:
        yield None


def func():
    with Spam.context() as ctx:  # No argument provided for required parameter `cls` (missing-argument) [Ln 12, Col 10]
        print("blah")

I imagine this is a bad interaction between the classmethod decorator and other decorators?

A

Version

ty 0.0.1-alpha.32 (84a1881 2025-12-05)

Metadata

Metadata

Assignees

Labels

genericsBugs or features relating to ty's generics implementation

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions