fastcore 2.2.35__tar.gz → 2.2.36__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fastcore-2.2.35/fastcore.egg-info → fastcore-2.2.36}/PKG-INFO +1 -1
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/__init__.py +1 -1
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/_modidx.py +1 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/docments.py +12 -2
- {fastcore-2.2.35 → fastcore-2.2.36/fastcore.egg-info}/PKG-INFO +1 -1
- {fastcore-2.2.35 → fastcore-2.2.36}/CONTRIBUTING.md +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/LICENSE +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/README.md +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/aio.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/all.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/ansi.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/apisurface.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/basics.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/dispatch.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/docscrape.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/editskill.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/foundation.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/funccall.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/imghdr.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/imports.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/meta.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/nb_imports.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/nbio.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/net.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/parallel.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/py2pyi.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/script.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/shutil.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/style.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/test.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/tools.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/transform.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/utils.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/xdg.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/xml.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore/xtras.py +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore.egg-info/SOURCES.txt +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore.egg-info/dependency_links.txt +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore.egg-info/entry_points.txt +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore.egg-info/requires.txt +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/fastcore.egg-info/top_level.txt +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/pyproject.toml +0 -0
- {fastcore-2.2.35 → fastcore-2.2.36}/setup.cfg +0 -0
|
@@ -358,6 +358,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
358
358
|
'fastcore.docments._callable_instance': ('docments.html#_callable_instance', 'fastcore/docments.py'),
|
|
359
359
|
'fastcore.docments._clean_comment': ('docments.html#_clean_comment', 'fastcore/docments.py'),
|
|
360
360
|
'fastcore.docments._clean_text_sig': ('docments.html#_clean_text_sig', 'fastcore/docments.py'),
|
|
361
|
+
'fastcore.docments._defines': ('docments.html#_defines', 'fastcore/docments.py'),
|
|
361
362
|
'fastcore.docments._docstring': ('docments.html#_docstring', 'fastcore/docments.py'),
|
|
362
363
|
'fastcore.docments._escape_markdown': ('docments.html#_escape_markdown', 'fastcore/docments.py'),
|
|
363
364
|
'fastcore.docments._fmt_default': ('docments.html#_fmt_default', 'fastcore/docments.py'),
|
|
@@ -65,13 +65,23 @@ def get_dataclass_source(s):
|
|
|
65
65
|
"Get source code for dataclass `s`"
|
|
66
66
|
return getsource(s) if not getattr(s, "__module__") == '__main__' else ""
|
|
67
67
|
|
|
68
|
+
def _defines(src, f):
|
|
69
|
+
"Whether `src` begins with function `f`'s decorators or `def`, and its first `def` has `f`'s name"
|
|
70
|
+
nm = f.__code__.co_name
|
|
71
|
+
if nm == '<lambda>': return True
|
|
72
|
+
d = re.search(r'^\s*(?:async\s+)?def\s+(\w+)', src, re.M)
|
|
73
|
+
return bool(re.match(r'\s*(@|(async\s+)?def\s)', src)) and bool(d) and d[1]==nm
|
|
74
|
+
|
|
68
75
|
def get_source(s):
|
|
69
76
|
"Get source for a function, callable implementation, dataclass, or source string"
|
|
70
77
|
if isinstance(s,str): return s
|
|
71
78
|
s = inspect.unwrap(s)
|
|
72
79
|
if isinstance(s, partial): s = s.func
|
|
73
80
|
if _callable_instance(s): s = s.__call__
|
|
74
|
-
|
|
81
|
+
if not (isfunction(s) or ismethod(s)): return get_dataclass_source(s) if isdataclass(s) else None
|
|
82
|
+
src,f = getsource(s),getattr(s, '__func__', s)
|
|
83
|
+
if not _defines(src, f): raise OSError(f"The source of `{f.__qualname__}` changed since it was imported; reload its module")
|
|
84
|
+
return src
|
|
75
85
|
|
|
76
86
|
# %% ../nbs/04_docments.ipynb #40e3f274
|
|
77
87
|
def _get_property_name(p):
|
|
@@ -106,7 +116,7 @@ def _parses(s):
|
|
|
106
116
|
try: return parse(dedent(get_source(s) or ''))
|
|
107
117
|
except SyntaxError:
|
|
108
118
|
if isinstance(s,str): raise
|
|
109
|
-
return parse('') # live object whose
|
|
119
|
+
return parse('') # a live object whose source line does not parse alone, such as a lambda inside a call: no docments
|
|
110
120
|
|
|
111
121
|
def _tokens(s):
|
|
112
122
|
"Tokenize Python code in string or function object `s`"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|