mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 21:46:42 +08:00
click: Use property decorator for read-only properties (#3028)
Since these properties do not have a setter, be explicit with the `@property` decorator. This will allow type checkers to see that assignment of these attributes is an error. See https://github.com/python/typeshed/pull/3027#discussion_r289623016 for some related context.
This commit is contained in:
committed by
Jelle Zijlstra
parent
018ecb3f16
commit
233f2abf19
18
third_party/2and3/click/core.pyi
vendored
18
third_party/2and3/click/core.pyi
vendored
@@ -65,10 +65,6 @@ class Context:
|
||||
_close_callbacks: List
|
||||
_depth: int
|
||||
|
||||
# properties
|
||||
meta: Dict[str, Any]
|
||||
command_path: str
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
command: Command,
|
||||
@@ -89,6 +85,14 @@ class Context:
|
||||
) -> None:
|
||||
...
|
||||
|
||||
@property
|
||||
def meta(self) -> Dict[str, Any]:
|
||||
...
|
||||
|
||||
@property
|
||||
def command_path(self) -> str:
|
||||
...
|
||||
|
||||
def scope(self, cleanup: bool = ...) -> ContextManager[Context]:
|
||||
...
|
||||
|
||||
@@ -370,8 +374,6 @@ class Parameter:
|
||||
is_eager: bool
|
||||
metavar: Optional[str]
|
||||
envvar: Union[str, List[str], None]
|
||||
# properties
|
||||
human_readable_name: str
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -388,6 +390,10 @@ class Parameter:
|
||||
) -> None:
|
||||
...
|
||||
|
||||
@property
|
||||
def human_readable_name(self) -> str:
|
||||
...
|
||||
|
||||
def make_metavar(self) -> str:
|
||||
...
|
||||
|
||||
|
||||
6
third_party/2and3/click/parser.pyi
vendored
6
third_party/2and3/click/parser.pyi
vendored
@@ -30,8 +30,6 @@ class Option:
|
||||
prefixes: Set[str]
|
||||
_short_opts: List[str]
|
||||
_long_opts: List[str]
|
||||
# properties
|
||||
takes_value: bool
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -44,6 +42,10 @@ class Option:
|
||||
) -> None:
|
||||
...
|
||||
|
||||
@property
|
||||
def takes_value(self) -> bool:
|
||||
...
|
||||
|
||||
def process(self, value: Any, state: ParsingState) -> None:
|
||||
...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user