File tree Expand file tree Collapse file tree 7 files changed +44
-4
lines changed Expand file tree Collapse file tree 7 files changed +44
-4
lines changed Original file line number Diff line number Diff line change 16
16
pypi_name : " domdf_python_tools"
17
17
env :
18
18
GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
19
+ if : startsWith(github.ref, 'refs/tags/') != true
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ known_third_party =
23
23
github
24
24
importlib_metadata
25
25
importlib_resources
26
+ natsort
26
27
packaging
27
28
pandas
28
29
pydash
Original file line number Diff line number Diff line change 44
44
rev : v1.7.0
45
45
hooks :
46
46
- id : python-no-eval
47
+ - id : rst-backticks
48
+ - id : rst-directive-colons
49
+ - id : rst-inline-touching-normal
47
50
48
51
- repo : https://github.com/asottile/pyupgrade
49
52
rev : v2.7.4
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ domdf_python_tools
28
28
- |license | |language | |requires | |pre_commit |
29
29
30
30
.. |docs | image :: https://img.shields.io/readthedocs/domdf_python_tools/latest?logo=read-the-docs
31
- :target: https://domdf_python_tools.readthedocs.io/en/latest/?badge=latest
31
+ :target: https://domdf_python_tools.readthedocs.io/en/latest
32
32
:alt: Documentation Build Status
33
33
34
34
.. |docs_check | image :: https://github.com/domdfcoding/domdf_python_tools/workflows/Docs%20Check/badge.svg
Original file line number Diff line number Diff line change 61
61
templates_path = ["_templates" ]
62
62
html_static_path = ["_static" ]
63
63
source_suffix = ".rst"
64
- exclude_patterns = []
65
-
66
64
master_doc = "index"
67
65
suppress_warnings = ["image.nonlocal_uri" ]
68
66
pygments_style = "default"
Original file line number Diff line number Diff line change
1
+ from functools import wraps
2
+ from types import FunctionType
3
+ from typing import Callable , List , NamedTuple
4
+
5
+
6
+ class Factory (NamedTuple ):
7
+ func : Callable
8
+
9
+ def __call__ (self ):
10
+ return self .func ()
11
+
12
+ def __repr__ (self ) -> str :
13
+ return f"{ type (self ).__name__ } ({ self .func !r} )"
14
+
15
+
16
+ def mutdef (func : FunctionType ) -> Callable :
17
+
18
+ @wraps (func )
19
+ def wrapper (* args , ** kwargs ):
20
+ print (func .__defaults__ )
21
+ defaults = func .__defaults__ or ()
22
+ func .__defaults__ = tuple (d () if isinstance (d , Factory ) else d for d in defaults )
23
+
24
+ return func (* args , ** kwargs )
25
+
26
+ return wrapper
27
+
28
+
29
+ @mutdef # type: ignore
30
+ def foo (name : str , occupations : List [str ] = Factory (list )):
31
+ print (f"name={ name } " )
32
+ print (f"occupations={ occupations } " )
33
+
34
+
35
+ if __name__ == '__main__' :
36
+ foo ("Wendy" )
37
+ foo ("Bob" , ["Builder" ])
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ long_description_content_type = text/x-rst
17
17
platforms = Windows, macOS, Linux
18
18
url = https://github.com/domdfcoding/domdf_python_tools
19
19
project_urls =
20
- Documentation = https://domdf_python_tools.readthedocs.io
20
+ Documentation = https://domdf_python_tools.readthedocs.io/en/latest
21
21
Issue_Tracker = https://github.com/domdfcoding/domdf_python_tools/issues
22
22
Source_Code = https://github.com/domdfcoding/domdf_python_tools
23
23
classifiers =
You can’t perform that action at this time.
0 commit comments