fastcore 2.2.31__tar.gz → 2.2.33__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.31/fastcore.egg-info → fastcore-2.2.33}/PKG-INFO +14 -16
  2. {fastcore-2.2.31 → fastcore-2.2.33}/README.md +13 -15
  3. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/__init__.py +14 -14
  4. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/_modidx.py +1 -0
  5. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/basics.py +4 -4
  6. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/docments.py +2 -2
  7. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/nbio.py +3 -3
  8. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/net.py +24 -14
  9. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/style.py +1 -1
  10. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/test.py +1 -1
  11. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/xdg.py +1 -1
  12. {fastcore-2.2.31 → fastcore-2.2.33/fastcore.egg-info}/PKG-INFO +14 -16
  13. {fastcore-2.2.31 → fastcore-2.2.33}/CONTRIBUTING.md +0 -0
  14. {fastcore-2.2.31 → fastcore-2.2.33}/LICENSE +0 -0
  15. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/aio.py +0 -0
  16. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/all.py +0 -0
  17. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/ansi.py +0 -0
  18. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/apisurface.py +0 -0
  19. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/dispatch.py +0 -0
  20. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/docscrape.py +0 -0
  21. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/editskill.py +0 -0
  22. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/foundation.py +0 -0
  23. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/funccall.py +0 -0
  24. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/imghdr.py +0 -0
  25. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/imports.py +0 -0
  26. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/meta.py +0 -0
  27. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/nb_imports.py +0 -0
  28. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/parallel.py +0 -0
  29. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/py2pyi.py +0 -0
  30. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/script.py +0 -0
  31. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/shutil.py +0 -0
  32. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/tools.py +0 -0
  33. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/transform.py +0 -0
  34. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/utils.py +0 -0
  35. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/xml.py +0 -0
  36. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore/xtras.py +0 -0
  37. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore.egg-info/SOURCES.txt +0 -0
  38. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore.egg-info/dependency_links.txt +0 -0
  39. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore.egg-info/entry_points.txt +0 -0
  40. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore.egg-info/requires.txt +0 -0
  41. {fastcore-2.2.31 → fastcore-2.2.33}/fastcore.egg-info/top_level.txt +0 -0
  42. {fastcore-2.2.31 → fastcore-2.2.33}/pyproject.toml +0 -0
  43. {fastcore-2.2.31 → fastcore-2.2.33}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastcore
3
- Version: 2.2.31
3
+ Version: 2.2.33
4
4
  Summary: Python supercharged for fastai development
5
5
  Author-email: Jeremy Howard and Sylvain Gugger <infos@fast.ai>
6
6
  License-Expression: Apache-2.0
@@ -44,19 +44,19 @@ Python is a powerful, dynamic language. Rather than bake everything into the lan
44
44
 
45
45
  Here are some tips on using fastcore:
46
46
 
47
- - **Liberal imports**: Use `from fastcore.module import *` freely. The library is designed for safe wildcard imports.
48
- - **Enhanced list operations**: Substitute `list` with [`L`](https://fastcore.fast.ai/foundation.html#l). This provides advanced indexing, method chaining, and additional functionality while maintaining list-like behavior.
49
- - **Extend existing classes**: Apply the `@patch` decorator to add methods to classes, including built-ins, without subclassing.
50
- - **Streamline class initialization**: In `__init__` methods, use [`store_attr()`](https://fastcore.fast.ai/basics.html#store_attr) to efficiently set multiple attributes, reducing repetitive assignment code.
51
- - **Explicit keyword arguments**: Apply the [`delegates`](https://fastcore.fast.ai/meta.html#delegates) decorator to functions to replace `**kwargs` with specific parameters, enhancing IDE support and documentation.
52
- - **Optimize parallel execution**: Use fastcore’s enhanced [`ThreadPoolExecutor`](https://fastcore.fast.ai/parallel.html#threadpoolexecutor) and [`ProcessPoolExecutor`](https://fastcore.fast.ai/parallel.html#processpoolexecutor) for simplified concurrent processing.
53
- - **Expressive testing**: Prefer fastcore’s testing functions like [`test_eq`](https://fastcore.fast.ai/test.html#test_eq), [`test_ne`](https://fastcore.fast.ai/test.html#test_ne), [`test_close`](https://fastcore.fast.ai/test.html#test_close) for more readable and informative test assertions.
54
- - **Advanced file operations**: Use the extended `Path` class, which adds methods like `ls()`, `read_json()`, and others to [`pathlib.Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path).
55
- - **Flexible data structures**: Convert between dictionaries and attribute-access objects using [`dict2obj`](https://fastcore.fast.ai/xtras.html#dict2obj) and [`obj2dict`](https://fastcore.fast.ai/xtras.html#obj2dict) for more intuitive data handling.
56
- - **Functional programming paradigms**: Use tools like [`compose`](https://fastcore.fast.ai/basics.html#compose), [`maps`](https://fastcore.fast.ai/basics.html#maps), and [`filter_ex`](https://fastcore.fast.ai/basics.html#filter_ex) to write more functional-style Python code.
57
- - **Documentation**: Document parameters and return values with [`docments`](https://fastcore.fast.ai/docments.html#docments), using source comments or `Annotated` metadata for generated APIs. [`MarkdownRenderer`](https://fastcore.fast.ai/docments.html#markdownrenderer) shows the effective signature and retains usage sections such as Notes, Raises, and Examples.
58
- - **Time-aware caching**: Apply the [`timed_cache`](https://fastcore.fast.ai/xtras.html#timed_cache) decorator to add time-based expiration to the standard `lru_cache` functionality.
59
- - **Simplified CLI creation**: Use `fastcore.script` to easily transform Python functions into command-line interfaces.
47
+ - Use `from fastcore.module import *` freely. fastcore’s modules are built to be safe for wildcard imports.
48
+ - Use [`L`](https://fastcore.fast.ai/foundation.html#l) in place of `list`. [`L`](https://fastcore.fast.ai/foundation.html#l) behaves like a list, with extra indexing options, method chaining and more methods.
49
+ - Add methods to existing classes, including built-ins, with the `@patch` decorator instead of subclassing.
50
+ - In `__init__` methods, call [`store_attr()`](https://fastcore.fast.ai/basics.html#store_attr) to set multiple attributes at once instead of assigning each one.
51
+ - Apply the [`delegates`](https://fastcore.fast.ai/meta.html#delegates) decorator to show a function’s real parameters in place of `**kwargs`, for IDEs and generated documentation.
52
+ - Use fastcore’s versions of [`ThreadPoolExecutor`](https://fastcore.fast.ai/parallel.html#threadpoolexecutor) and [`ProcessPoolExecutor`](https://fastcore.fast.ai/parallel.html#processpoolexecutor) for simpler concurrent processing.
53
+ - Prefer fastcore’s test functions, such as [`test_eq`](https://fastcore.fast.ai/test.html#test_eq), [`test_ne`](https://fastcore.fast.ai/test.html#test_ne) and [`test_close`](https://fastcore.fast.ai/test.html#test_close), for assertions that read clearly and give informative failures.
54
+ - fastcore extends [`pathlib.Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path) with methods such as `ls()` and `read_json()`.
55
+ - Convert between dictionaries and objects with attribute access using [`dict2obj`](https://fastcore.fast.ai/xtras.html#dict2obj) and [`obj2dict`](https://fastcore.fast.ai/xtras.html#obj2dict).
56
+ - Write in a functional style with tools such as [`compose`](https://fastcore.fast.ai/basics.html#compose), [`maps`](https://fastcore.fast.ai/basics.html#maps) and [`filter_ex`](https://fastcore.fast.ai/basics.html#filter_ex).
57
+ - Document parameters and return values with [`docments`](https://fastcore.fast.ai/docments.html#docments), using source comments or `Annotated` metadata for generated APIs. [`MarkdownRenderer`](https://fastcore.fast.ai/docments.html#markdownrenderer) shows the effective signature and keeps usage sections such as Notes, Raises and Examples.
58
+ - Apply the [`timed_cache`](https://fastcore.fast.ai/xtras.html#timed_cache) decorator to add time-based expiry to the standard `lru_cache`.
59
+ - Turn Python functions into command-line interfaces with `fastcore.script`.
60
60
 
61
61
  For example, [`L`](https://fastcore.fast.ai/foundation.html#l) is a drop-in replacement for `list` with extra superpowers:
62
62
 
@@ -88,8 +88,6 @@ To install fastcore run: `conda install fastcore -c fastai` (if you use Anaconda
88
88
 
89
89
  To get started, we recommend you read through [the fastcore tour](https://fastcore.fast.ai/tour.html).
90
90
 
91
- [`globtastic`](https://fastcore.fast.ai/xtras.html#globtastic) supports filename filters (`file_glob`, `file_re`) and full-path filters (`path_glob`, `path_re`). Glob filters use `fnmatch`: `*` matches directory separators and `**` has no special meaning.
92
-
93
91
  ## Contributing
94
92
 
95
93
  After you clone this repository, please run `nbdev_install_hooks` in your terminal. This sets up git hooks, which clean up the notebooks to remove the extraneous stuff stored in the notebooks (e.g. which cells you ran) which causes unnecessary merge conflicts.
@@ -13,19 +13,19 @@ Python is a powerful, dynamic language. Rather than bake everything into the lan
13
13
 
14
14
  Here are some tips on using fastcore:
15
15
 
16
- - **Liberal imports**: Use `from fastcore.module import *` freely. The library is designed for safe wildcard imports.
17
- - **Enhanced list operations**: Substitute `list` with [`L`](https://fastcore.fast.ai/foundation.html#l). This provides advanced indexing, method chaining, and additional functionality while maintaining list-like behavior.
18
- - **Extend existing classes**: Apply the `@patch` decorator to add methods to classes, including built-ins, without subclassing.
19
- - **Streamline class initialization**: In `__init__` methods, use [`store_attr()`](https://fastcore.fast.ai/basics.html#store_attr) to efficiently set multiple attributes, reducing repetitive assignment code.
20
- - **Explicit keyword arguments**: Apply the [`delegates`](https://fastcore.fast.ai/meta.html#delegates) decorator to functions to replace `**kwargs` with specific parameters, enhancing IDE support and documentation.
21
- - **Optimize parallel execution**: Use fastcore’s enhanced [`ThreadPoolExecutor`](https://fastcore.fast.ai/parallel.html#threadpoolexecutor) and [`ProcessPoolExecutor`](https://fastcore.fast.ai/parallel.html#processpoolexecutor) for simplified concurrent processing.
22
- - **Expressive testing**: Prefer fastcore’s testing functions like [`test_eq`](https://fastcore.fast.ai/test.html#test_eq), [`test_ne`](https://fastcore.fast.ai/test.html#test_ne), [`test_close`](https://fastcore.fast.ai/test.html#test_close) for more readable and informative test assertions.
23
- - **Advanced file operations**: Use the extended `Path` class, which adds methods like `ls()`, `read_json()`, and others to [`pathlib.Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path).
24
- - **Flexible data structures**: Convert between dictionaries and attribute-access objects using [`dict2obj`](https://fastcore.fast.ai/xtras.html#dict2obj) and [`obj2dict`](https://fastcore.fast.ai/xtras.html#obj2dict) for more intuitive data handling.
25
- - **Functional programming paradigms**: Use tools like [`compose`](https://fastcore.fast.ai/basics.html#compose), [`maps`](https://fastcore.fast.ai/basics.html#maps), and [`filter_ex`](https://fastcore.fast.ai/basics.html#filter_ex) to write more functional-style Python code.
26
- - **Documentation**: Document parameters and return values with [`docments`](https://fastcore.fast.ai/docments.html#docments), using source comments or `Annotated` metadata for generated APIs. [`MarkdownRenderer`](https://fastcore.fast.ai/docments.html#markdownrenderer) shows the effective signature and retains usage sections such as Notes, Raises, and Examples.
27
- - **Time-aware caching**: Apply the [`timed_cache`](https://fastcore.fast.ai/xtras.html#timed_cache) decorator to add time-based expiration to the standard `lru_cache` functionality.
28
- - **Simplified CLI creation**: Use `fastcore.script` to easily transform Python functions into command-line interfaces.
16
+ - Use `from fastcore.module import *` freely. fastcore’s modules are built to be safe for wildcard imports.
17
+ - Use [`L`](https://fastcore.fast.ai/foundation.html#l) in place of `list`. [`L`](https://fastcore.fast.ai/foundation.html#l) behaves like a list, with extra indexing options, method chaining and more methods.
18
+ - Add methods to existing classes, including built-ins, with the `@patch` decorator instead of subclassing.
19
+ - In `__init__` methods, call [`store_attr()`](https://fastcore.fast.ai/basics.html#store_attr) to set multiple attributes at once instead of assigning each one.
20
+ - Apply the [`delegates`](https://fastcore.fast.ai/meta.html#delegates) decorator to show a function’s real parameters in place of `**kwargs`, for IDEs and generated documentation.
21
+ - Use fastcore’s versions of [`ThreadPoolExecutor`](https://fastcore.fast.ai/parallel.html#threadpoolexecutor) and [`ProcessPoolExecutor`](https://fastcore.fast.ai/parallel.html#processpoolexecutor) for simpler concurrent processing.
22
+ - Prefer fastcore’s test functions, such as [`test_eq`](https://fastcore.fast.ai/test.html#test_eq), [`test_ne`](https://fastcore.fast.ai/test.html#test_ne) and [`test_close`](https://fastcore.fast.ai/test.html#test_close), for assertions that read clearly and give informative failures.
23
+ - fastcore extends [`pathlib.Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path) with methods such as `ls()` and `read_json()`.
24
+ - Convert between dictionaries and objects with attribute access using [`dict2obj`](https://fastcore.fast.ai/xtras.html#dict2obj) and [`obj2dict`](https://fastcore.fast.ai/xtras.html#obj2dict).
25
+ - Write in a functional style with tools such as [`compose`](https://fastcore.fast.ai/basics.html#compose), [`maps`](https://fastcore.fast.ai/basics.html#maps) and [`filter_ex`](https://fastcore.fast.ai/basics.html#filter_ex).
26
+ - Document parameters and return values with [`docments`](https://fastcore.fast.ai/docments.html#docments), using source comments or `Annotated` metadata for generated APIs. [`MarkdownRenderer`](https://fastcore.fast.ai/docments.html#markdownrenderer) shows the effective signature and keeps usage sections such as Notes, Raises and Examples.
27
+ - Apply the [`timed_cache`](https://fastcore.fast.ai/xtras.html#timed_cache) decorator to add time-based expiry to the standard `lru_cache`.
28
+ - Turn Python functions into command-line interfaces with `fastcore.script`.
29
29
 
30
30
  For example, [`L`](https://fastcore.fast.ai/foundation.html#l) is a drop-in replacement for `list` with extra superpowers:
31
31
 
@@ -57,8 +57,6 @@ To install fastcore run: `conda install fastcore -c fastai` (if you use Anaconda
57
57
 
58
58
  To get started, we recommend you read through [the fastcore tour](https://fastcore.fast.ai/tour.html).
59
59
 
60
- [`globtastic`](https://fastcore.fast.ai/xtras.html#globtastic) supports filename filters (`file_glob`, `file_re`) and full-path filters (`path_glob`, `path_re`). Glob filters use `fnmatch`: `*` matches directory separators and `**` has no special meaning.
61
-
62
60
  ## Contributing
63
61
 
64
62
  After you clone this repository, please run `nbdev_install_hooks` in your terminal. This sets up git hooks, which clean up the notebooks to remove the extraneous stuff stored in the notebooks (e.g. which cells you ran) which causes unnecessary merge conflicts.
@@ -4,19 +4,19 @@ Python is a powerful, dynamic language. Rather than bake everything into the lan
4
4
 
5
5
  Here are some tips on using fastcore:
6
6
 
7
- - **Liberal imports**: Use `from fastcore.module import *` freely. The library is designed for safe wildcard imports.
8
- - **Enhanced list operations**: Substitute `list` with `L`. This provides advanced indexing, method chaining, and additional functionality while maintaining list-like behavior.
9
- - **Extend existing classes**: Apply the `@patch` decorator to add methods to classes, including built-ins, without subclassing.
10
- - **Streamline class initialization**: In `__init__` methods, use `store_attr()` to efficiently set multiple attributes, reducing repetitive assignment code.
11
- - **Explicit keyword arguments**: Apply the `delegates` decorator to functions to replace `**kwargs` with specific parameters, enhancing IDE support and documentation.
12
- - **Optimize parallel execution**: Use fastcore's enhanced `ThreadPoolExecutor` and `ProcessPoolExecutor` for simplified concurrent processing.
13
- - **Expressive testing**: Prefer fastcore's testing functions like `test_eq`, `test_ne`, `test_close` for more readable and informative test assertions.
14
- - **Advanced file operations**: Use the extended `Path` class, which adds methods like `ls()`, `read_json()`, and others to `pathlib.Path`.
15
- - **Flexible data structures**: Convert between dictionaries and attribute-access objects using `dict2obj` and `obj2dict` for more intuitive data handling.
16
- - **Functional programming paradigms**: Use tools like `compose`, `maps`, and `filter_ex` to write more functional-style Python code.
17
- - **Documentation**: Document parameters and return values with `docments`, using source comments or `Annotated` metadata for generated APIs. `MarkdownRenderer` shows the effective signature and retains usage sections such as Notes, Raises, and Examples.
18
- - **Time-aware caching**: Apply the `timed_cache` decorator to add time-based expiration to the standard `lru_cache` functionality.
19
- - **Simplified CLI creation**: Use `fastcore.script` to easily transform Python functions into command-line interfaces.
7
+ - Use `from fastcore.module import *` freely. fastcore's modules are built to be safe for wildcard imports.
8
+ - Use `L` in place of `list`. `L` behaves like a list, with extra indexing options, method chaining and more methods.
9
+ - Add methods to existing classes, including built-ins, with the `@patch` decorator instead of subclassing.
10
+ - In `__init__` methods, call `store_attr()` to set multiple attributes at once instead of assigning each one.
11
+ - Apply the `delegates` decorator to show a function's real parameters in place of `**kwargs`, for IDEs and generated documentation.
12
+ - Use fastcore's versions of `ThreadPoolExecutor` and `ProcessPoolExecutor` for simpler concurrent processing.
13
+ - Prefer fastcore's test functions, such as `test_eq`, `test_ne` and `test_close`, for assertions that read clearly and give informative failures.
14
+ - fastcore extends `pathlib.Path` with methods such as `ls()` and `read_json()`.
15
+ - Convert between dictionaries and objects with attribute access using `dict2obj` and `obj2dict`.
16
+ - Write in a functional style with tools such as `compose`, `maps` and `filter_ex`.
17
+ - Document parameters and return values with `docments`, using source comments or `Annotated` metadata for generated APIs. `MarkdownRenderer` shows the effective signature and keeps usage sections such as Notes, Raises and Examples.
18
+ - Apply the `timed_cache` decorator to add time-based expiry to the standard `lru_cache`.
19
+ - Turn Python functions into command-line interfaces with `fastcore.script`.
20
20
 
21
21
  For example, `L` is a drop-in replacement for `list` with extra superpowers:
22
22
 
@@ -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.31"
58
+ __version__ = "2.2.33"
@@ -656,6 +656,7 @@ d = { 'settings': { 'branch': 'main',
656
656
  'fastcore.net._SafeRedirectHandler': ('net.html#_saferedirecthandler', 'fastcore/net.py'),
657
657
  'fastcore.net._SafeRedirectHandler.redirect_request': ( 'net.html#_saferedirecthandler.redirect_request',
658
658
  'fastcore/net.py'),
659
+ 'fastcore.net._http_exc': ('net.html#_http_exc', 'fastcore/net.py'),
659
660
  'fastcore.net._socket_det': ('net.html#_socket_det', 'fastcore/net.py'),
660
661
  'fastcore.net._waitfor': ('net.html#_waitfor', 'fastcore/net.py'),
661
662
  'fastcore.net.free_port': ('net.html#free_port', 'fastcore/net.py'),
@@ -1,10 +1,10 @@
1
1
  """Basic functionality used in the fastai library
2
2
 
3
- The staples used throughout fastai code, each replacing a common multi-line pattern with a one-liner: `ifnone(a,b)` is `b if a is None else a` (though both args are always evaluated); `listify` and `tuplify` convert anything to a list or tuple the way you'd mean it (`None` becomes `[]`, a `str` or `dict` stays a single item, a generator is consumed); and `basic_repr('a,b')` gives a class a deterministic `key=value` repr with no memory address, so notebook and git diffs stay clean.
3
+ The staples used throughout fastai code, each replacing a common multi-line pattern with a one-liner.
4
4
 
5
5
  Curried versions of the comparison and arithmetic functions in Python's `operator` module: `lt gt le ge eq ne add sub mul truediv is_ is_not in_ mod`. With two args they work like `operator`'s versions; with one arg they return a partial that binds it as the *second* argument, so `lt(3)` means "is less than 3" and `in_(vals)` means "is contained in `vals`". They read especially well as `cmp` arguments to `fastcore.test.test`, e.g. `test(x, valid, in_)`.
6
6
 
7
- `AttrDict` is a `dict` whose keys are also attributes, so `d.foo` reads and writes `d['foo']` (to convert a whole nested structure at once, see `dict2obj` in `fastcore.xtras`); `NS` is the same idea built on `SimpleNamespace`, adding indexing and iteration. `store_attr()`, called inside `__init__`, stores the function's arguments as attributes of `self` in one line:
7
+ `store_attr()`, called inside `__init__`, stores the function's arguments as attributes of `self` in one line:
8
8
 
9
9
  ```python
10
10
  class Point:
@@ -13,7 +13,7 @@ p = Point(1, 2)
13
13
  test_eq((p.x, p.y, p.scale), (1, 2, 1))
14
14
  ```
15
15
 
16
- Tools for making and transforming functions: `compose(f,g,...)` chains functions left to right; `bind` is `partial` extended with `arg0`,`arg1`,... placeholders for reordering positional arguments; and `fail_clean` re-raises exceptions with the library's own traceback frames stripped, for errors that are part of a function's contract rather than bugs.
16
+ Utilities for functional programming or for defining, modifying, or debugging functions.
17
17
 
18
18
  `~Self` is a concise alternative to `lambda` for a function that operates on a single object (note the capitalization!). Write the chain of attribute accesses, method calls, and indexing just as you would after a variable name, with `~Self` in its place, and the result is a plain function that runs the chain on its argument:
19
19
 
@@ -25,7 +25,7 @@ Tools for making and transforming functions: `compose(f,g,...)` chains functions
25
25
 
26
26
  Since `.`, `()`, and `[]` bind tighter than `~`, the whole chain builds first and `~` then converts it to a function, so the chain never needs its own parentheses: `map(~Self.imag, nums)` works as written.
27
27
 
28
- `@patch` adds a function to an existing class as a method, using the function's `self:` type annotation to pick the class (a union annotation patches several classes at once); `@patch_to(Cls)` is the same with the class passed explicitly. Both take `as_prop`, `set_prop`, and `cls_method`. fastai code uses this to build classes incrementally across a notebook, so expect to find a class's methods defined far from the class itself:
28
+ fastai code builds classes incrementally across a notebook. A class's methods often appear far from the class itself. `@patch` adds a function to an existing class as a method, and picks the class from the function's `self:` annotation:
29
29
 
30
30
  ```python
31
31
  @patch
@@ -44,7 +44,7 @@ def docstring(sym):
44
44
  if isinstance(sym, partial): return docstring(sym.func)
45
45
  if _callable_instance(sym):
46
46
  own = inspect.getattr_static(sym, '__doc__', None)
47
- if own is not getattr(type(sym), '__doc__', None): return getdoc(sym) or ''
47
+ if isinstance(own, property) or own is not getattr(type(sym), '__doc__', None): return getdoc(sym) or ''
48
48
  return getdoc(sym.__call__) or getdoc(sym) or ''
49
49
  res = getdoc(sym)
50
50
  if not getattr(sym, '__doc__', None) and res == object.__init__.__doc__: res = None
@@ -183,7 +183,7 @@ def docments(s, full=False, eval_str=False, returns=True, args_kwargs=False):
183
183
  except (ValueError, TypeError): return AttrDict()
184
184
  nps = parse_docstring(s)
185
185
  docs = {}
186
- while s:
186
+ while s is not None:
187
187
  p = _param_locs(s, returns=returns, args_kwargs=args_kwargs) or {}
188
188
  c = {o.start[0]:_clean_comment(o.string) for o in _tokens(s) if o.type==COMMENT}
189
189
  for k,v in p.items():
@@ -1,10 +1,10 @@
1
1
  """Reading, writing, and running Jupyter notebooks
2
2
 
3
- Cell tools apply `fastcore.tools`' string editing primitives to one notebook cell's source, addressed by path and cell id, mirroring that module's file tools: the same operations and parameters, with `path, cell_id` in place of `path`. Each editor (including the structural `cell_ast_replace`) returns a diff of the change, and `view_cell` shows a cell's source with optional line numbers or exhash addresses.
3
+ The cell tools apply `fastcore.tools`' string editing primitives to one notebook cell's source. They match that module's file tools, with the same operations and parameters, but take `path, cell_id` where the file tools take `path`. Every editor, including the structural `cell_ast_replace`, returns a diff of its change. `view_cell` shows a cell's source with optional line numbers or exhash addresses.
4
4
 
5
- Naming and parameter conventions shared across the editing toolkit are documented in `fastcore.editskill`, which also re-exports this module's editing tools.
5
+ `fastcore.editskill` documents the naming and parameter conventions shared across the editing toolkit, and re-exports this module's editing tools.
6
6
 
7
- `diff_cells` compares two versions of a cell sequence -- an open notebook against its file on disk, a dialog against an edited copy -- and yields the edits that turn one into the other. Items are aligned by `id` (any objects with `.id` work, not just cells), and each edit is a *block*: a contiguous run of deletions, insertions, or in-place changes, so an applier can handle a whole run at once and inserted items keep their order. Identity questions ride the ids; whether an aligned pair *changed* is a content question, answered by comparing `key(item)` on each side.
7
+ `diff_cells` compares two versions of a cell sequence, such as an open notebook and its file on disk, or a dialog and an edited copy. It yields the edits that turn one into the other. It aligns items by `id`, and works with any objects that have an `.id`, not just cells. Each edit is a *block* covering a contiguous run of deletions, insertions or in-place changes. An applier can handle each block in one step, keeping inserted items in order. An aligned pair counts as changed when `key(item)` differs between the two sides.
8
8
 
9
9
  Docs: https://fastcore.fast.ai/nbio.html.md"""
10
10
 
@@ -1,6 +1,6 @@
1
1
  """Network, HTTP, and URL functions
2
2
 
3
- `urlread`/`urljson` retrieve a URL (POSTing when `data` or kwargs are given), `urlsave` downloads to a file named from the URL, and `urlopen` wraps `urllib` with quoting, header, and data handling; on HTTP failure they raise a status-specific exception (`HTTP404NotFoundError`, ...), each a subclass of `HTTP4xxClientError` or `HTTP5xxServerError`, with the response body included in the message. `start_server`/`start_client` make TCP — or, passing a string `port`, Unix-socket — connections; `waitfor` polls a callable until truthy with a timeout; and `is_port_free`/`wait_port_free` help coordinate with servers.
3
+ Every URL function here goes through `urlopen`. It quotes the URL, sends `url_default_headers`, and encodes `data`. On an HTTP error it raises the status-specific exception for the code, such as `HTTP404NotFoundError` or `HTTP503ServiceUnavailableError`. Each is a subclass of `HTTP4xxClientError` or `HTTP5xxServerError`. Its message includes the response body. The module also has TCP and Unix-socket clients and servers, and helpers that wait for a condition or a free port.
4
4
 
5
5
  Docs: https://fastcore.fast.ai/net.html.md"""
6
6
 
@@ -19,7 +19,11 @@ __all__ = ['url_default_headers', 'ExceptionsHTTP', 'urlquote', 'urlwrap', 'HTTP
19
19
  'HTTP418AmAteapotError', 'HTTP421MisdirectedRequestError', 'HTTP422UnprocessableEntityError',
20
20
  'HTTP423LockedError', 'HTTP424FailedDependencyError', 'HTTP425TooEarlyError', 'HTTP426UpgradeRequiredError',
21
21
  'HTTP428PreconditionRequiredError', 'HTTP429TooManyRequestsError', 'HTTP431HeaderFieldsTooLargeError',
22
- 'HTTP451LegalReasonsError']
22
+ 'HTTP451LegalReasonsError', 'HTTP500InternalServerError', 'HTTP501NotImplementedError',
23
+ 'HTTP502BadGatewayError', 'HTTP503ServiceUnavailableError', 'HTTP504GatewayTimeoutError',
24
+ 'HTTP505HTTPVersionNotSupportedError', 'HTTP506VariantAlsoNegotiatesError',
25
+ 'HTTP507InsufficientStorageError', 'HTTP508LoopDetectedError', 'HTTP510NotExtendedError',
26
+ 'HTTP511NetworkAuthenticationRequiredError']
23
27
 
24
28
  # %% ../nbs/03b_net.ipynb #05c808e7
25
29
  from .utils import *
@@ -99,18 +103,28 @@ _httperrors = ((400,'Bad Request'),(401,'Unauthorized'),(402,'Payment Required')
99
103
  (414,'URI Too Long'),(415,'Unsupported Media Type'),(416,'Range Not Satisfiable'),(417,'Expectation Failed'),
100
104
  (418,'Am A teapot'),(421,'Misdirected Request'),(422,'Unprocessable Entity'),(423,'Locked'),(424,'Failed Dependency'),
101
105
  (425,'Too Early'),(426,'Upgrade Required'),(428,'Precondition Required'),(429,'Too Many Requests'),
102
- (431,'Header Fields Too Large'),(451,'Legal Reasons'))
106
+ (431,'Header Fields Too Large'),(451,'Legal Reasons'),(500,'Internal Server Error'),(501,'Not Implemented'),
107
+ (502,'Bad Gateway'),(503,'Service Unavailable'),(504,'Gateway Timeout'),(505,'HTTP Version Not Supported'),
108
+ (506,'Variant Also Negotiates'),(507,'Insufficient Storage'),(508,'Loop Detected'),(510,'Not Extended'),
109
+ (511,'Network Authentication Required'))
103
110
 
104
111
  for code,msg in _httperrors:
105
- nm = f'HTTP{code}{msg.replace(" ","")}Error'
106
- def _init(self, url, hdrs, fp, msg=msg, code=code): HTTP4xxClientError.__init__(self, url, code, msg, hdrs, fp)
107
- cls = type(nm, (HTTP4xxClientError,), {'__init__':_init})
112
+ base = HTTP4xxClientError if code<500 else HTTP5xxServerError
113
+ nm = f'HTTP{code}{msg.replace(" ","").removesuffix("Error")}Error'
114
+ def _init(self, url, hdrs, fp, msg=msg, code=code, base=base): base.__init__(self, url, code, msg, hdrs, fp)
115
+ cls = type(nm, (base,), {'__init__':_init})
108
116
  globals()[nm] = ExceptionsHTTP[code] = cls
109
117
 
110
118
  # %% ../nbs/03b_net.ipynb #21fa32a4
111
- _all_ = ['HTTP400BadRequestError', 'HTTP401UnauthorizedError', 'HTTP402PaymentRequiredError', 'HTTP403ForbiddenError', 'HTTP404NotFoundError', 'HTTP405MethodNotAllowedError', 'HTTP406NotAcceptableError', 'HTTP407ProxyAuthRequiredError', 'HTTP408RequestTimeoutError', 'HTTP409ConflictError', 'HTTP410GoneError', 'HTTP411LengthRequiredError', 'HTTP412PreconditionFailedError', 'HTTP413PayloadTooLargeError', 'HTTP414URITooLongError', 'HTTP415UnsupportedMediaTypeError', 'HTTP416RangeNotSatisfiableError', 'HTTP417ExpectationFailedError', 'HTTP418AmAteapotError', 'HTTP421MisdirectedRequestError', 'HTTP422UnprocessableEntityError', 'HTTP423LockedError', 'HTTP424FailedDependencyError', 'HTTP425TooEarlyError', 'HTTP426UpgradeRequiredError', 'HTTP428PreconditionRequiredError', 'HTTP429TooManyRequestsError', 'HTTP431HeaderFieldsTooLargeError', 'HTTP451LegalReasonsError']
119
+ _all_ = ['HTTP400BadRequestError', 'HTTP401UnauthorizedError', 'HTTP402PaymentRequiredError', 'HTTP403ForbiddenError', 'HTTP404NotFoundError', 'HTTP405MethodNotAllowedError', 'HTTP406NotAcceptableError', 'HTTP407ProxyAuthRequiredError', 'HTTP408RequestTimeoutError', 'HTTP409ConflictError', 'HTTP410GoneError', 'HTTP411LengthRequiredError', 'HTTP412PreconditionFailedError', 'HTTP413PayloadTooLargeError', 'HTTP414URITooLongError', 'HTTP415UnsupportedMediaTypeError', 'HTTP416RangeNotSatisfiableError', 'HTTP417ExpectationFailedError', 'HTTP418AmAteapotError', 'HTTP421MisdirectedRequestError', 'HTTP422UnprocessableEntityError', 'HTTP423LockedError', 'HTTP424FailedDependencyError', 'HTTP425TooEarlyError', 'HTTP426UpgradeRequiredError', 'HTTP428PreconditionRequiredError', 'HTTP429TooManyRequestsError', 'HTTP431HeaderFieldsTooLargeError', 'HTTP451LegalReasonsError', 'HTTP500InternalServerError', 'HTTP501NotImplementedError', 'HTTP502BadGatewayError', 'HTTP503ServiceUnavailableError', 'HTTP504GatewayTimeoutError', 'HTTP505HTTPVersionNotSupportedError', 'HTTP506VariantAlsoNegotiatesError', 'HTTP507InsufficientStorageError', 'HTTP508LoopDetectedError', 'HTTP510NotExtendedError', 'HTTP511NetworkAuthenticationRequiredError']
112
120
 
113
121
  # %% ../nbs/03b_net.ipynb #0d72881c
122
+ def _http_exc(e):
123
+ "The status-specific exception for `HTTPError` `e`, or `e` itself outside 4xx and 5xx"
124
+ if e.code in ExceptionsHTTP: return ExceptionsHTTP[e.code](e.url, e.hdrs, e.fp, msg=e.msg)
125
+ if 400 <= e.code < 600: return (HTTP4xxClientError if e.code<500 else HTTP5xxServerError)(e.url, e.code, e.msg, e.hdrs, e.fp)
126
+ return e
127
+
114
128
  def urlopen(url, data=None, headers=None, timeout=None, **kwargs):
115
129
  "Like `urllib.request.urlopen`, but first `urlwrap` the `url`, and encode `data`"
116
130
  if kwargs and not data: data=kwargs
@@ -118,18 +132,14 @@ def urlopen(url, data=None, headers=None, timeout=None, **kwargs):
118
132
  if not isinstance(data, strtyps): data = urlencode(data)
119
133
  if not isinstance(data, bytes): data = data.encode('ascii')
120
134
  try: return urlopener().open(urlwrap(url, data=data, headers=headers), timeout=timeout)
121
- except HTTPError as e:
135
+ except HTTPError as e:
122
136
  e.msg += f"\n====Error Body====\n{e.read().decode(errors='ignore')}"
123
- raise
137
+ raise _http_exc(e) from None
124
138
 
125
139
  # %% ../nbs/03b_net.ipynb #fa6a4dfe
126
140
  def urlread(url, data=None, headers=None, decode=True, return_json=False, return_headers=False, timeout=None, **kwargs):
127
141
  "Retrieve `url`, using `data` dict or `kwargs` to `POST` if present"
128
- try:
129
- with urlopen(url, data=data, headers=headers, timeout=timeout, **kwargs) as u: res,hdrs = u.read(),u.headers
130
- except HTTPError as e:
131
- if 400 <= e.code < 500: raise ExceptionsHTTP[e.code](e.url, e.hdrs, e.fp, msg=e.msg) from None
132
- else: raise
142
+ with urlopen(url, data=data, headers=headers, timeout=timeout, **kwargs) as u: res,hdrs = u.read(),u.headers
133
143
 
134
144
  if decode: res = res.decode()
135
145
  if return_json: res = loads(res)
@@ -1,6 +1,6 @@
1
1
  """Fast styling for friendly CLIs.
2
2
 
3
- Build ANSI terminal styles by chaining attributes on the exported `S` object, then apply by calling with a string: `S.blue.bold('hi')` returns the escaped string, nesting correctly inside other styles. Chains are plain objects, so a style can be defined once and reused; tab completion on `S.` lists the available colors and effects.
3
+ Build an ANSI terminal style by chaining attributes on the exported `S` object, then apply it by calling it with a string. `S.blue.bold('hi')` returns the escaped string, which nests correctly inside other styles. A chain is a plain object that can be defined once and reused. Tab completion on `S.` lists the available colors and effects.
4
4
 
5
5
  Docs: https://fastcore.fast.ai/style.html.md"""
6
6
 
@@ -1,6 +1,6 @@
1
1
  """Helper functions to quickly write tests in notebooks
2
2
 
3
- All the helpers here wrap `test(a,b,cmp)`: an `assert cmp(a,b)` that shows both values when the comparison fails, rather than a bare `AssertionError`. The named comparisons are `test_eq`, `test_ne`, `test_eq_type` (equal and same type), `test_close` (within `eps`, default 1e-5), `test_is`, `test_shuffled` (equal ignoring order), `test_stdout` (what `f` prints), and `test_warns`.
3
+ All the helpers here wrap `test(a,b,cmp)`, an `assert cmp(a,b)` that shows both values when the comparison fails, rather than a bare `AssertionError`.
4
4
 
5
5
  To check that code fails as expected, use `test_fail(f, contains=..., exc=...)` for a callable, or `expect_fail` as a context manager, which also accepts `regex`:
6
6
 
@@ -1,6 +1,6 @@
1
1
  """XDG Base Directory Specification helpers.
2
2
 
3
- `xdg_cache_home`, `xdg_config_home`, `xdg_data_home`, `xdg_state_home`, and `xdg_runtime_dir` each return the `Path` given by their `XDG_*` environment variable, falling back to the [spec](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)'s default (`~/.cache`, `~/.config`, `~/.local/share`, `~/.local/state`; `None` for the runtime dir) when it's unset, empty, or relative. `xdg_config_dirs` and `xdg_data_dirs` likewise return the colon-split search-path lists.
3
+ Each helper reads one `XDG_*` environment variable and falls back to the [spec](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)'s default when the variable is unset or empty. The single-path helpers also fall back when the variable holds a relative path. The `*_DIRS` helpers split the variable on colons and drop relative entries. `xdg_runtime_dir` has no default and returns `None`.
4
4
 
5
5
  Docs: https://fastcore.fast.ai/xdg.html.md"""
6
6
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastcore
3
- Version: 2.2.31
3
+ Version: 2.2.33
4
4
  Summary: Python supercharged for fastai development
5
5
  Author-email: Jeremy Howard and Sylvain Gugger <infos@fast.ai>
6
6
  License-Expression: Apache-2.0
@@ -44,19 +44,19 @@ Python is a powerful, dynamic language. Rather than bake everything into the lan
44
44
 
45
45
  Here are some tips on using fastcore:
46
46
 
47
- - **Liberal imports**: Use `from fastcore.module import *` freely. The library is designed for safe wildcard imports.
48
- - **Enhanced list operations**: Substitute `list` with [`L`](https://fastcore.fast.ai/foundation.html#l). This provides advanced indexing, method chaining, and additional functionality while maintaining list-like behavior.
49
- - **Extend existing classes**: Apply the `@patch` decorator to add methods to classes, including built-ins, without subclassing.
50
- - **Streamline class initialization**: In `__init__` methods, use [`store_attr()`](https://fastcore.fast.ai/basics.html#store_attr) to efficiently set multiple attributes, reducing repetitive assignment code.
51
- - **Explicit keyword arguments**: Apply the [`delegates`](https://fastcore.fast.ai/meta.html#delegates) decorator to functions to replace `**kwargs` with specific parameters, enhancing IDE support and documentation.
52
- - **Optimize parallel execution**: Use fastcore’s enhanced [`ThreadPoolExecutor`](https://fastcore.fast.ai/parallel.html#threadpoolexecutor) and [`ProcessPoolExecutor`](https://fastcore.fast.ai/parallel.html#processpoolexecutor) for simplified concurrent processing.
53
- - **Expressive testing**: Prefer fastcore’s testing functions like [`test_eq`](https://fastcore.fast.ai/test.html#test_eq), [`test_ne`](https://fastcore.fast.ai/test.html#test_ne), [`test_close`](https://fastcore.fast.ai/test.html#test_close) for more readable and informative test assertions.
54
- - **Advanced file operations**: Use the extended `Path` class, which adds methods like `ls()`, `read_json()`, and others to [`pathlib.Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path).
55
- - **Flexible data structures**: Convert between dictionaries and attribute-access objects using [`dict2obj`](https://fastcore.fast.ai/xtras.html#dict2obj) and [`obj2dict`](https://fastcore.fast.ai/xtras.html#obj2dict) for more intuitive data handling.
56
- - **Functional programming paradigms**: Use tools like [`compose`](https://fastcore.fast.ai/basics.html#compose), [`maps`](https://fastcore.fast.ai/basics.html#maps), and [`filter_ex`](https://fastcore.fast.ai/basics.html#filter_ex) to write more functional-style Python code.
57
- - **Documentation**: Document parameters and return values with [`docments`](https://fastcore.fast.ai/docments.html#docments), using source comments or `Annotated` metadata for generated APIs. [`MarkdownRenderer`](https://fastcore.fast.ai/docments.html#markdownrenderer) shows the effective signature and retains usage sections such as Notes, Raises, and Examples.
58
- - **Time-aware caching**: Apply the [`timed_cache`](https://fastcore.fast.ai/xtras.html#timed_cache) decorator to add time-based expiration to the standard `lru_cache` functionality.
59
- - **Simplified CLI creation**: Use `fastcore.script` to easily transform Python functions into command-line interfaces.
47
+ - Use `from fastcore.module import *` freely. fastcore’s modules are built to be safe for wildcard imports.
48
+ - Use [`L`](https://fastcore.fast.ai/foundation.html#l) in place of `list`. [`L`](https://fastcore.fast.ai/foundation.html#l) behaves like a list, with extra indexing options, method chaining and more methods.
49
+ - Add methods to existing classes, including built-ins, with the `@patch` decorator instead of subclassing.
50
+ - In `__init__` methods, call [`store_attr()`](https://fastcore.fast.ai/basics.html#store_attr) to set multiple attributes at once instead of assigning each one.
51
+ - Apply the [`delegates`](https://fastcore.fast.ai/meta.html#delegates) decorator to show a function’s real parameters in place of `**kwargs`, for IDEs and generated documentation.
52
+ - Use fastcore’s versions of [`ThreadPoolExecutor`](https://fastcore.fast.ai/parallel.html#threadpoolexecutor) and [`ProcessPoolExecutor`](https://fastcore.fast.ai/parallel.html#processpoolexecutor) for simpler concurrent processing.
53
+ - Prefer fastcore’s test functions, such as [`test_eq`](https://fastcore.fast.ai/test.html#test_eq), [`test_ne`](https://fastcore.fast.ai/test.html#test_ne) and [`test_close`](https://fastcore.fast.ai/test.html#test_close), for assertions that read clearly and give informative failures.
54
+ - fastcore extends [`pathlib.Path`](https://docs.python.org/3/library/pathlib.html#pathlib.Path) with methods such as `ls()` and `read_json()`.
55
+ - Convert between dictionaries and objects with attribute access using [`dict2obj`](https://fastcore.fast.ai/xtras.html#dict2obj) and [`obj2dict`](https://fastcore.fast.ai/xtras.html#obj2dict).
56
+ - Write in a functional style with tools such as [`compose`](https://fastcore.fast.ai/basics.html#compose), [`maps`](https://fastcore.fast.ai/basics.html#maps) and [`filter_ex`](https://fastcore.fast.ai/basics.html#filter_ex).
57
+ - Document parameters and return values with [`docments`](https://fastcore.fast.ai/docments.html#docments), using source comments or `Annotated` metadata for generated APIs. [`MarkdownRenderer`](https://fastcore.fast.ai/docments.html#markdownrenderer) shows the effective signature and keeps usage sections such as Notes, Raises and Examples.
58
+ - Apply the [`timed_cache`](https://fastcore.fast.ai/xtras.html#timed_cache) decorator to add time-based expiry to the standard `lru_cache`.
59
+ - Turn Python functions into command-line interfaces with `fastcore.script`.
60
60
 
61
61
  For example, [`L`](https://fastcore.fast.ai/foundation.html#l) is a drop-in replacement for `list` with extra superpowers:
62
62
 
@@ -88,8 +88,6 @@ To install fastcore run: `conda install fastcore -c fastai` (if you use Anaconda
88
88
 
89
89
  To get started, we recommend you read through [the fastcore tour](https://fastcore.fast.ai/tour.html).
90
90
 
91
- [`globtastic`](https://fastcore.fast.ai/xtras.html#globtastic) supports filename filters (`file_glob`, `file_re`) and full-path filters (`path_glob`, `path_re`). Glob filters use `fnmatch`: `*` matches directory separators and `**` has no special meaning.
92
-
93
91
  ## Contributing
94
92
 
95
93
  After you clone this repository, please run `nbdev_install_hooks` in your terminal. This sets up git hooks, which clean up the notebooks to remove the extraneous stuff stored in the notebooks (e.g. which cells you ran) which causes unnecessary merge conflicts.
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