Skip to content

v0.4.0

Latest
Compare
Choose a tag to compare
@lagru lagru released this 10 Aug 15:04
· 6 commits to main since this release
v0.4.0
7fce493

docstub 0.4.0

We're happy to announce the release of docstub 0.4.0! 🎉

Highlights

  • Inline annotations override types in docstrings
    This provides a fallback and a solution in case docstub is missing support or if Python's type system can't express what you want to say in the docstring (#61).

  • Derive types from import statements in parsed files
    Types imported in your project are made implicitly available to reference in docstrings. You no longer need to declare them explicitly in configuration (#63).

  • Ignore files
    A new command line option --ignore and a config option ignore_files now help you ignore files you don't want to create stubs for (#60).

Find a more detailed list of pull requests contributing to this release below.

Enhancement

  • Ensure that existing inline annotations aren't overridden by annotations in docstrings. This allows documenting types inside docstrings that are not (yet) supported by Python's type system. Instead, more general inlined type annotations can be used as a fallback. Previously, annotations in docstrings would take precedence (#61).
  • Add new command line option --ignore and config option ignore_files. Both allow ignoring directories or files in the package directory that docstub is invoked on (#60).
  • Use import statements in the parsed package to collect additional type information. This makes imported types available in the same module scope to be used in docstrings. Some of the imports can be used package wide even if not imported there. E.g. from pathlib import Path will allow using "Path" inside the modules scope. Outside of that module, you must use the full pathlib.Path to reference that type (#63).
  • Type nicknames specified in the configuration are now resolved recursively. That means one nickname can point to another nickname (#63).
  • Add --no-cache option to docstub run which avoids creating or reading to a cache entirely; mostly useful during development. Also note when the cache is used during type collection (#69).
  • Add docstub clean command to remove temporary files such as the cache directory (#69).
  • Relax grammar for specifying optional and additional information after type descriptions in docstrings. You can now specify as much optional information after the first top-level comma as you want and in arbitrary order, e.g., some_param: int, in range (0, 1), optional. This optional information is ignored by docstub (#70).

Bug Fixes

  • Avoid an AttributeError when using a union of dtypes in an array expression (#52).
  • Support referencing types from collections.abc and typing with their module name included. So collections.abc.Iterable should work now (#53).
  • Make sure that no warning is raised for inline annotations, if there is no conflicting annotation in a docstring. Otherwise, the inlined annotation takes precedence and a warning is printed (#66).
  • Nesting natural language containers didn't work in all cases. Now, doctypes like list of (list of int) will work. For complex nested types, falling back to Python's typing syntax might be more readable though (#71).

Documentation

  • Add a reference document for the configuration file (#60).

DevOps

  • Fix broken diff check due to changed output behavior (#54).
  • Add pull request template for changelist (#67).

Maintenance

  • Improve walking of the source directory (#68).
  • Prepare release of version 0.4.0 (#72).

Contributors

2 authors added to this release (alphabetically):

2 reviewers added to this release (alphabetically):