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 1616 pypi_name : " domdf_python_tools"
1717 env :
1818 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 =
2323 github
2424 importlib_metadata
2525 importlib_resources
26+ natsort
2627 packaging
2728 pandas
2829 pydash
Original file line number Diff line number Diff line change 4444 rev : v1.7.0
4545 hooks :
4646 - id : python-no-eval
47+ - id : rst-backticks
48+ - id : rst-directive-colons
49+ - id : rst-inline-touching-normal
4750
4851 - repo : https://github.com/asottile/pyupgrade
4952 rev : v2.7.4
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ domdf_python_tools
2828 - |license | |language | |requires | |pre_commit |
2929
3030.. |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
3232 :alt: Documentation Build Status
3333
3434.. |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 6161templates_path = ["_templates" ]
6262html_static_path = ["_static" ]
6363source_suffix = ".rst"
64- exclude_patterns = []
65-
6664master_doc = "index"
6765suppress_warnings = ["image.nonlocal_uri" ]
6866pygments_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
1717platforms = Windows, macOS, Linux
1818url = https://github.com/domdfcoding/domdf_python_tools
1919project_urls =
20- Documentation = https://domdf_python_tools.readthedocs.io
20+ Documentation = https://domdf_python_tools.readthedocs.io/en/latest
2121 Issue_Tracker = https://github.com/domdfcoding/domdf_python_tools/issues
2222 Source_Code = https://github.com/domdfcoding/domdf_python_tools
2323classifiers =
You can’t perform that action at this time.
0 commit comments