mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-08-02 06:00:24 +08:00
Decouple types.DynamicClassAttribute from property (#13276)
This commit is contained in:
@@ -25,8 +25,6 @@ posixpath.join
|
||||
ntpath.join
|
||||
os.path.join
|
||||
|
||||
types.DynamicClassAttribute..* # In the stub we pretend it's an alias for property, but it has positional-only differences
|
||||
|
||||
# typing.IO uses positional-or-keyword arguments, but in the stubs we prefer
|
||||
# to mark these as positional-only for compatibility with existing sub-classes.
|
||||
typing(_extensions)?\.BinaryIO\.write
|
||||
|
||||
@@ -46,8 +46,6 @@ posixpath.join
|
||||
ntpath.join
|
||||
os.path.join
|
||||
|
||||
types.DynamicClassAttribute..* # In the stub we pretend it's an alias for property, but it has positional-only differences
|
||||
|
||||
# typing.IO uses positional-or-keyword arguments, but in the stubs we prefer
|
||||
# to mark these as positional-only for compatibility with existing sub-classes.
|
||||
typing(_extensions)?\.BinaryIO\.write
|
||||
|
||||
@@ -45,8 +45,6 @@ posixpath.join
|
||||
ntpath.join
|
||||
os.path.join
|
||||
|
||||
types.DynamicClassAttribute..* # In the stub we pretend it's an alias for property, but it has positional-only differences
|
||||
|
||||
# typing.IO uses positional-or-keyword arguments, but in the stubs we prefer
|
||||
# to mark these as positional-only for compatibility with existing sub-classes.
|
||||
typing(_extensions)?\.BinaryIO\.write
|
||||
|
||||
@@ -45,8 +45,6 @@ posixpath.join
|
||||
ntpath.join
|
||||
os.path.join
|
||||
|
||||
types.DynamicClassAttribute..* # In the stub we pretend it's an alias for property, but it has positional-only differences
|
||||
|
||||
# typing.IO uses positional-or-keyword arguments, but in the stubs we prefer
|
||||
# to mark these as positional-only for compatibility with existing sub-classes.
|
||||
typing(_extensions)?\.BinaryIO\.write
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import types
|
||||
from collections import UserDict
|
||||
@@ -39,3 +41,20 @@ item_3 = mp.get(3, "default")
|
||||
assert_type(item_3, Union[int, str])
|
||||
# Default isn't accepted as a keyword argument.
|
||||
mp.get(4, default="default") # type: ignore
|
||||
|
||||
|
||||
# test: `types.DynamicClassAttribute`
|
||||
class DCAtest:
|
||||
_value: int | None = None
|
||||
|
||||
@types.DynamicClassAttribute
|
||||
def foo(self) -> int | None:
|
||||
return self._value
|
||||
|
||||
@foo.setter
|
||||
def foo(self, value: int) -> None:
|
||||
self._value = value
|
||||
|
||||
@foo.deleter
|
||||
def foo(self) -> None:
|
||||
self._value = None
|
||||
|
||||
Reference in New Issue
Block a user