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

Experiment: decouple types.DynamicClassAttribute from property #12762

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/py310.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ _collections_abc.Generator.send
_collections_abc.Generator.throw

# typing.SupportsRound.__round__ # pos-or-kw at runtime, but we pretend it's pos-only in the stub so that e.g. float.__round__ satisfies the interface
types.DynamicClassAttribute..* # In the stub we pretend it's an alias for property, but it has positional-only differences

# These three have a pos-or-keyword first parameter at runtime, but deliberately have a pos-only first parameter in the stub. #6812
posixpath.join
Expand Down
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/py311.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ _collections_abc.Generator.send
_collections_abc.Generator.throw

# typing.SupportsRound.__round__ # pos-or-kw at runtime, but we pretend it's pos-only in the stub so that e.g. float.__round__ satisfies the interface
types.DynamicClassAttribute..* # In the stub we pretend it's an alias for property, but it has positional-only differences

# These three have a pos-or-keyword first parameter at runtime, but deliberately have a pos-only first parameter in the stub. #6812
posixpath.join
Expand Down
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/py312.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ _collections_abc.Generator.send
_collections_abc.Generator.throw

# typing.SupportsRound.__round__ # pos-or-kw at runtime, but we pretend it's pos-only in the stub so that e.g. float.__round__ satisfies the interface
types.DynamicClassAttribute..* # In the stub we pretend it's an alias for property, but it has positional-only differences

# These three have a pos-or-keyword first parameter at runtime, but deliberately have a pos-only first parameter in the stub. #6812
posixpath.join
Expand Down
1 change: 0 additions & 1 deletion stdlib/@tests/stubtest_allowlists/py313.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ _collections_abc.Generator.send
_collections_abc.Generator.throw

# typing.SupportsRound.__round__ # pos-or-kw at runtime, but we pretend it's pos-only in the stub so that e.g. float.__round__ satisfies the interface
types.DynamicClassAttribute..* # In the stub we pretend it's an alias for property, but it has positional-only differences

# These three have a pos-or-keyword first parameter at runtime, but deliberately have a pos-only first parameter in the stub. #6812
posixpath.join
Expand Down
21 changes: 19 additions & 2 deletions stdlib/types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,25 @@ def prepare_class(
if sys.version_info >= (3, 12):
def get_original_bases(cls: type, /) -> tuple[Any, ...]: ...

# Actually a different type, but `property` is special and we want that too.
DynamicClassAttribute = property
class DynamicClassAttribute(property):
fget: Callable[[Any], Any] | None
fset: Callable[[Any, Any], None] | None
fdel: Callable[[Any], None] | None
overwrite_doc: bool
__isabstractmethod__: bool
def __init__(
self,
fget: Callable[[Any], Any] | None = ...,
fset: Callable[[Any, Any], None] | None = ...,
fdel: Callable[[Any], None] | None = ...,
doc: str | None = ...,
) -> None: ...
def __get__(self, instance: Any, ownerclass: type | None = None) -> Any: ...
def __set__(self, instance: Any, value: Any) -> None: ...
def __delete__(self, instance: Any) -> None: ...
def getter(self, fget: Callable[[Any], Any]) -> property: ...
def setter(self, fset: Callable[[Any, Any], None]) -> property: ...
def deleter(self, fdel: Callable[[Any], None]) -> property: ...

_Fn = TypeVar("_Fn", bound=Callable[..., object])
_R = TypeVar("_R")
Expand Down
Loading