fastcore 2.2.29__tar.gz → 2.2.30__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.
Files changed (43) hide show
  1. {fastcore-2.2.29/fastcore.egg-info → fastcore-2.2.30}/PKG-INFO +2 -2
  2. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/__init__.py +1 -1
  3. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/_modidx.py +1 -11
  4. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/script.py +19 -11
  5. {fastcore-2.2.29 → fastcore-2.2.30/fastcore.egg-info}/PKG-INFO +2 -2
  6. {fastcore-2.2.29 → fastcore-2.2.30}/pyproject.toml +2 -2
  7. {fastcore-2.2.29 → fastcore-2.2.30}/CONTRIBUTING.md +0 -0
  8. {fastcore-2.2.29 → fastcore-2.2.30}/LICENSE +0 -0
  9. {fastcore-2.2.29 → fastcore-2.2.30}/README.md +0 -0
  10. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/aio.py +0 -0
  11. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/all.py +0 -0
  12. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/ansi.py +0 -0
  13. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/apisurface.py +0 -0
  14. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/basics.py +0 -0
  15. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/dispatch.py +0 -0
  16. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/docments.py +0 -0
  17. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/docscrape.py +0 -0
  18. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/editskill.py +0 -0
  19. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/foundation.py +0 -0
  20. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/funccall.py +0 -0
  21. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/imghdr.py +0 -0
  22. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/imports.py +0 -0
  23. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/meta.py +0 -0
  24. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/nb_imports.py +0 -0
  25. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/nbio.py +0 -0
  26. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/net.py +0 -0
  27. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/parallel.py +0 -0
  28. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/py2pyi.py +0 -0
  29. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/shutil.py +0 -0
  30. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/style.py +0 -0
  31. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/test.py +0 -0
  32. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/tools.py +0 -0
  33. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/transform.py +0 -0
  34. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/utils.py +0 -0
  35. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/xdg.py +0 -0
  36. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/xml.py +0 -0
  37. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore/xtras.py +0 -0
  38. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore.egg-info/SOURCES.txt +0 -0
  39. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore.egg-info/dependency_links.txt +0 -0
  40. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore.egg-info/entry_points.txt +0 -0
  41. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore.egg-info/requires.txt +0 -0
  42. {fastcore-2.2.29 → fastcore-2.2.30}/fastcore.egg-info/top_level.txt +0 -0
  43. {fastcore-2.2.29 → fastcore-2.2.30}/setup.cfg +0 -0
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastcore
3
- Version: 2.2.29
3
+ Version: 2.2.30
4
4
  Summary: Python supercharged for fastai development
5
5
  Author-email: Jeremy Howard and Sylvain Gugger <infos@fast.ai>
6
- License: Apache-2.0
6
+ License-Expression: Apache-2.0
7
7
  Project-URL: Repository, https://github.com/AnswerDotAI/fastcore/
8
8
  Project-URL: Documentation, https://fastcore.fast.ai/
9
9
  Keywords: python
@@ -55,4 +55,4 @@ Modules:
55
55
  - `fastcore.xml`: Concise HTML generation and namespace-aware XML construction.
56
56
  - `fastcore.xtras`: Utility functions used in the fastai library"""
57
57
 
58
- __version__ = "2.2.29"
58
+ __version__ = "2.2.30"
@@ -33,8 +33,6 @@ d = { 'settings': { 'branch': 'main',
33
33
  'fastcore.aio.then': ('aio.html#then', 'fastcore/aio.py'),
34
34
  'fastcore.aio.to_aiter': ('aio.html#to_aiter', 'fastcore/aio.py'),
35
35
  'fastcore.aio.wait_until': ('aio.html#wait_until', 'fastcore/aio.py')},
36
- 'fastcore.all': {},
37
- 'fastcore.ansi': {},
38
36
  'fastcore.apisurface': { 'fastcore.apisurface.OpGroup': ('apisurface.html#opgroup', 'fastcore/apisurface.py'),
39
37
  'fastcore.apisurface.OpGroup.__allow__': ( 'apisurface.html#opgroup.__allow__',
40
38
  'fastcore/apisurface.py'),
@@ -306,7 +304,6 @@ d = { 'settings': { 'branch': 'main',
306
304
  'fastcore.basics.wrap_class': ('basics.html#wrap_class', 'fastcore/basics.py'),
307
305
  'fastcore.basics.xdumps': ('basics.html#xdumps', 'fastcore/basics.py'),
308
306
  'fastcore.basics.zip_cycle': ('basics.html#zip_cycle', 'fastcore/basics.py')},
309
- 'fastcore.dispatch': {},
310
307
  'fastcore.docments': { 'fastcore.docments.DocmentList': ('docments.html#docmentlist', 'fastcore/docments.py'),
311
308
  'fastcore.docments.DocmentList._fmt': ('docments.html#docmentlist._fmt', 'fastcore/docments.py'),
312
309
  'fastcore.docments.DocmentList._repr_markdown_': ( 'docments.html#docmentlist._repr_markdown_',
@@ -392,8 +389,6 @@ d = { 'settings': { 'branch': 'main',
392
389
  'fastcore.docments.qual_name': ('docments.html#qual_name', 'fastcore/docments.py'),
393
390
  'fastcore.docments.sig2str': ('docments.html#sig2str', 'fastcore/docments.py'),
394
391
  'fastcore.docments.sig_source': ('docments.html#sig_source', 'fastcore/docments.py')},
395
- 'fastcore.docscrape': {},
396
- 'fastcore.editskill': {},
397
392
  'fastcore.foundation': { 'fastcore.foundation.CollBase': ('foundation.html#collbase', 'fastcore/foundation.py'),
398
393
  'fastcore.foundation.CollBase.__delitem__': ( 'foundation.html#collbase.__delitem__',
399
394
  'fastcore/foundation.py'),
@@ -513,8 +508,6 @@ d = { 'settings': { 'branch': 'main',
513
508
  'fastcore.funccall.resolve_nm': ('funccall.html#resolve_nm', 'fastcore/funccall.py'),
514
509
  'fastcore.funccall.schema2sig': ('funccall.html#schema2sig', 'fastcore/funccall.py'),
515
510
  'fastcore.funccall.union_schema': ('funccall.html#union_schema', 'fastcore/funccall.py')},
516
- 'fastcore.imghdr': {},
517
- 'fastcore.imports': {},
518
511
  'fastcore.meta': { 'fastcore.meta.AutoInit': ('meta.html#autoinit', 'fastcore/meta.py'),
519
512
  'fastcore.meta.AutoInit.__pre_init__': ('meta.html#autoinit.__pre_init__', 'fastcore/meta.py'),
520
513
  'fastcore.meta.BypassNewMeta': ('meta.html#bypassnewmeta', 'fastcore/meta.py'),
@@ -541,7 +534,6 @@ d = { 'settings': { 'branch': 'main',
541
534
  'fastcore.meta.test_sig': ('meta.html#test_sig', 'fastcore/meta.py'),
542
535
  'fastcore.meta.use_kwargs': ('meta.html#use_kwargs', 'fastcore/meta.py'),
543
536
  'fastcore.meta.use_kwargs_dict': ('meta.html#use_kwargs_dict', 'fastcore/meta.py')},
544
- 'fastcore.nb_imports': {},
545
537
  'fastcore.nbio': { 'fastcore.nbio.CellRow': ('nbio.html#cellrow', 'fastcore/nbio.py'),
546
538
  'fastcore.nbio.CellRow.__init__': ('nbio.html#cellrow.__init__', 'fastcore/nbio.py'),
547
539
  'fastcore.nbio.CellRow.__repr__': ('nbio.html#cellrow.__repr__', 'fastcore/nbio.py'),
@@ -753,10 +745,10 @@ d = { 'settings': { 'branch': 'main',
753
745
  'fastcore.script.bool_arg': ('script.html#bool_arg', 'fastcore/script.py'),
754
746
  'fastcore.script.call_parse': ('script.html#call_parse', 'fastcore/script.py'),
755
747
  'fastcore.script.is_cli': ('script.html#is_cli', 'fastcore/script.py'),
748
+ 'fastcore.script.parse_cli': ('script.html#parse_cli', 'fastcore/script.py'),
756
749
  'fastcore.script.set_ctx': ('script.html#set_ctx', 'fastcore/script.py'),
757
750
  'fastcore.script.store_false': ('script.html#store_false', 'fastcore/script.py'),
758
751
  'fastcore.script.store_true': ('script.html#store_true', 'fastcore/script.py')},
759
- 'fastcore.shutil': {},
760
752
  'fastcore.style': { 'fastcore.style.Style': ('style.html#style', 'fastcore/style.py'),
761
753
  'fastcore.style.Style.__call__': ('style.html#style.__call__', 'fastcore/style.py'),
762
754
  'fastcore.style.Style.__dir__': ('style.html#style.__dir__', 'fastcore/style.py'),
@@ -801,8 +793,6 @@ d = { 'settings': { 'branch': 'main',
801
793
  'fastcore.tools.str_replace': ('tools.html#str_replace', 'fastcore/tools.py'),
802
794
  'fastcore.tools.strs_replace': ('tools.html#strs_replace', 'fastcore/tools.py'),
803
795
  'fastcore.tools.view_file': ('tools.html#view_file', 'fastcore/tools.py')},
804
- 'fastcore.transform': {},
805
- 'fastcore.utils': {},
806
796
  'fastcore.xdg': { 'fastcore.xdg._path_from_env': ('xdg.html#_path_from_env', 'fastcore/xdg.py'),
807
797
  'fastcore.xdg._paths_from_env': ('xdg.html#_paths_from_env', 'fastcore/xdg.py'),
808
798
  'fastcore.xdg.xdg_cache_home': ('xdg.html#xdg_cache_home', 'fastcore/xdg.py'),
@@ -79,6 +79,8 @@ Enums show their choices as `{choice,...}`. Positional parameters show their nam
79
79
 
80
80
  Union types such as `int|str` try each type in turn, and `enum` types such as those from `str_enum` become argparse choices.
81
81
 
82
+ `parse_cli` is the argument-handling half of a `call_parse` run. It parses `sys.argv` for `func`. It returns the positional arguments, the keyword arguments, and whether `--pdb` was passed. `call_parse` then calls `func` with them. Use `parse_cli` to write a decorator that reads arguments as `call_parse` does and runs `func` some other way. [warmpy](https://github.com/AnswerDotAI/warmpy) runs it in a warm background process.
83
+
82
84
  ## The CLI entry point
83
85
 
84
86
  `call_parse` parses `sys.argv` when you run the function's file directly with `python foo.py`, `python -m foo` or `%run foo.py`. It also parses arguments on a zero-argument call from the top-level body of a directly run file. Console-script wrappers use this form.
@@ -130,8 +132,8 @@ Docs: https://fastcore.fast.ai/script.html.md"""
130
132
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/06_script.ipynb.
131
133
 
132
134
  # %% auto #0
133
- __all__ = ['store_true', 'store_false', 'bool_arg', 'anno2str', 'anno_parser', 'args_from_prog', 'set_ctx', 'call_parse',
134
- 'is_cli', 'CliError']
135
+ __all__ = ['store_true', 'store_false', 'bool_arg', 'anno2str', 'anno_parser', 'args_from_prog', 'set_ctx', 'parse_cli',
136
+ 'call_parse', 'is_cli', 'CliError']
135
137
 
136
138
  # %% ../nbs/06_script.ipynb #8a36db98
137
139
  import inspect,argparse,shutil,types,asyncio,importlib.metadata
@@ -303,20 +305,26 @@ def _pos_split(func, args):
303
305
  ks.append(k)
304
306
  return [],args
305
307
 
308
+ # %% ../nbs/06_script.ipynb #1456b39c
309
+ def parse_cli(func, nested=False, pos:list=None):
310
+ "Positional args, keyword args, and the `--pdb` flag that `sys.argv` gives for `func`"
311
+ if len(sys.argv)>1 and sys.argv[1]=='': sys.argv.pop(1)
312
+ p = anno_parser(func, pos=pos)
313
+ if nested: args, sys.argv[1:] = p.parse_known_args()
314
+ else: args = p.parse_args()
315
+ args = args.__dict__
316
+ xtra = otherwise(args.pop('xtra', ''), eq(1), p.prog)
317
+ pdb = args.pop('pdb', False)
318
+ return *_pos_split(func, merge(args, args_from_prog(func, xtra))), pdb
319
+
306
320
  # %% ../nbs/06_script.ipynb #dee5e259
307
321
  _cli_func = ContextVar('_cli_func', default=None)
308
322
 
309
323
  def _run_cli(func, nested, pos=None):
310
- "Parse `sys.argv` with `anno_parser` and call `func` with the result"
324
+ "Call `func` with the arguments `parse_cli` reads from `sys.argv`"
311
325
  with set_ctx(_cli_func, func):
312
- if len(sys.argv)>1 and sys.argv[1]=='': sys.argv.pop(1)
313
- p = anno_parser(func, pos=pos)
314
- if nested: args, sys.argv[1:] = p.parse_known_args()
315
- else: args = p.parse_args()
316
- args = args.__dict__
317
- xtra = otherwise(args.pop('xtra', ''), eq(1), p.prog)
318
- tfunc = trace(func) if args.pop('pdb', False) else func
319
- pargs,args = _pos_split(func, merge(args, args_from_prog(func, xtra)))
326
+ pargs,args,pdb = parse_cli(func, nested, pos)
327
+ tfunc = trace(func) if pdb else func
320
328
  try:
321
329
  res = tfunc(*pargs, **args)
322
330
  if inspect.isawaitable(res): res = asyncio.run(res)
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastcore
3
- Version: 2.2.29
3
+ Version: 2.2.30
4
4
  Summary: Python supercharged for fastai development
5
5
  Author-email: Jeremy Howard and Sylvain Gugger <infos@fast.ai>
6
- License: Apache-2.0
6
+ License-Expression: Apache-2.0
7
7
  Project-URL: Repository, https://github.com/AnswerDotAI/fastcore/
8
8
  Project-URL: Documentation, https://fastcore.fast.ai/
9
9
  Keywords: python
@@ -1,5 +1,5 @@
1
1
  [build-system]
2
- requires = ["setuptools>=64"]
2
+ requires = ["setuptools>=77"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
@@ -8,7 +8,7 @@ dynamic = ["version"]
8
8
  description = "Python supercharged for fastai development"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
11
- license = {text = "Apache-2.0"}
11
+ license = "Apache-2.0"
12
12
  authors = [{name = "Jeremy Howard and Sylvain Gugger", email = "infos@fast.ai"}]
13
13
  keywords = ['python']
14
14
  classifiers = ["Natural Language :: English", "Intended Audience :: Developers", "Development Status :: 5 - Production/Stable", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only"]
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