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

Show attrs auto_detect incompleteness #16704

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions test-data/unit/check-plugin-attrs.test
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,42 @@ reveal_type(A.__attrs_init__) # N: Revealed type is "def (self: __main__.A, b:

[builtins fixtures/plugin_attrs.pyi]

[case testAttrsInitMethodGeneratedWhenAutoDetectTrue]
from typing import Tuple
import attr

@attr.define(auto_detect=True)
class A:
b: int
c: str
def __init__(self, bc: Tuple[int, str]) -> None:
b, c = bc
self.__attrs_init__(b, c)

reveal_type(A) # N: Revealed type is "def (bc: Tuple[builtins.int, builtins.str]) -> __main__.A"
reveal_type(A.__init__) # N: Revealed type is "def (self: __main__.A, bc: Tuple[builtins.int, builtins.str])"
reveal_type(A.__attrs_init__) # N: Revealed type is "def (self: __main__.A, b: builtins.int, c: builtins.str)"

[builtins fixtures/plugin_attrs.pyi]

[case testAttrsInitMethodGeneratedWhenAutoDetectTrueDefault]
from typing import Tuple
import attr

@attr.define
class A:
b: int
c: str
def __init__(self, bc: Tuple[int, str]) -> None:
b, c = bc
self.__attrs_init__(b, c)

reveal_type(A) # N: Revealed type is "def (bc: Tuple[builtins.int, builtins.str]) -> __main__.A"
reveal_type(A.__init__) # N: Revealed type is "def (self: __main__.A, bc: Tuple[builtins.int, builtins.str])"
reveal_type(A.__attrs_init__) # N: Revealed type is "def (self: __main__.A, b: builtins.int, c: builtins.str)"

[builtins fixtures/plugin_attrs.pyi]

[case testAttrsClassWithSlots]
import attr

Expand Down
Loading