-
-
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.
Fix
sphinx.ext.autodoc.preserve_defaults
(#11550)
Co-authored-by: Adam Turner <[email protected]>
- Loading branch information
Showing
6 changed files
with
305 additions
and
9 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
50 changes: 50 additions & 0 deletions
50
tests/roots/test-ext-autodoc/target/preserve_defaults_special_constructs.py
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from __future__ import annotations | ||
|
||
from collections import namedtuple | ||
from dataclasses import dataclass, field | ||
from typing import NamedTuple, TypedDict | ||
|
||
#: docstring | ||
SENTINEL = object() | ||
|
||
|
||
#: docstring | ||
ze_lambda = lambda z=SENTINEL: None | ||
|
||
|
||
def foo(x, y, z=SENTINEL): | ||
"""docstring""" | ||
|
||
|
||
@dataclass | ||
class DataClass: | ||
"""docstring""" | ||
a: int | ||
b: object = SENTINEL | ||
c: list[int] = field(default_factory=lambda: [1, 2, 3]) | ||
|
||
|
||
@dataclass(init=False) | ||
class DataClassNoInit: | ||
"""docstring""" | ||
a: int | ||
b: object = SENTINEL | ||
c: list[int] = field(default_factory=lambda: [1, 2, 3]) | ||
|
||
|
||
class MyTypedDict(TypedDict): | ||
"""docstring""" | ||
a: int | ||
b: object | ||
c: list[int] | ||
|
||
|
||
class MyNamedTuple1(NamedTuple): | ||
"""docstring""" | ||
a: int | ||
b: object = object() | ||
c: list[int] = [1, 2, 3] | ||
|
||
|
||
class MyNamedTuple2(namedtuple('Base', ('a', 'b'), defaults=(0, SENTINEL))): | ||
"""docstring""" |
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