-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
autodoc: Fix warnings with dataclasses in
Annotated
metadata (#12622
- Loading branch information
Showing
7 changed files
with
134 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,42 @@ | ||
from __future__ import annotations | ||
# from __future__ import annotations | ||
|
||
import dataclasses | ||
import types | ||
from typing import Annotated | ||
|
||
|
||
@dataclasses.dataclass(frozen=True) | ||
class FuncValidator: | ||
func: types.FunctionType | ||
|
||
|
||
@dataclasses.dataclass(frozen=True) | ||
class MaxLen: | ||
max_length: int | ||
whitelisted_words: list[str] | ||
|
||
|
||
def validate(value: str) -> str: | ||
return value | ||
|
||
|
||
#: Type alias for a validated string. | ||
ValidatedString = Annotated[str, FuncValidator(validate)] | ||
|
||
|
||
def hello(name: Annotated[str, "attribute"]) -> None: | ||
"""docstring""" | ||
pass | ||
|
||
|
||
class AnnotatedAttributes: | ||
"""docstring""" | ||
|
||
#: Docstring about the ``name`` attribute. | ||
name: Annotated[str, "attribute"] | ||
|
||
#: Docstring about the ``max_len`` attribute. | ||
max_len: list[Annotated[str, MaxLen(10, ['word_one', 'word_two'])]] | ||
|
||
#: Docstring about the ``validated`` attribute. | ||
validated: ValidatedString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters