Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-sphinx-autodoc-typehints for openSUSE:Factory checked in at 2021-08-03 22:48:56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-sphinx-autodoc-typehints (Old) and /work/SRC/openSUSE:Factory/.python-sphinx-autodoc-typehints.new.1899 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-sphinx-autodoc-typehints" Tue Aug 3 22:48:56 2021 rev:8 rq:909938 version:1.12.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-sphinx-autodoc-typehints/python-sphinx-autodoc-typehints.changes 2021-04-24 23:10:14.183486717 +0200 +++ /work/SRC/openSUSE:Factory/.python-sphinx-autodoc-typehints.new.1899/python-sphinx-autodoc-typehints.changes 2021-08-03 22:49:28.816443347 +0200 @@ -1,0 +2,10 @@ +Tue Aug 3 09:42:00 UTC 2021 - Matej Cepl <mc...@suse.com> + +- Update to 1.12.0: + - Dropped Python 3.5 support + - Added the simplify_optional_unions config option + - Fixed indentation of multiline strings + - Changed formatting of None to point to the Python stdlib docs + - Updated special dataclass handling + +------------------------------------------------------------------- Old: ---- sphinx-autodoc-typehints-1.11.0.tar.gz New: ---- sphinx-autodoc-typehints-1.12.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-sphinx-autodoc-typehints.spec ++++++ --- /var/tmp/diff_new_pack.JEnhir/_old 2021-08-03 22:49:29.260442812 +0200 +++ /var/tmp/diff_new_pack.JEnhir/_new 2021-08-03 22:49:29.260442812 +0200 @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-sphinx-autodoc-typehints -Version: 1.11.0 +Version: 1.12.0 Release: 0 Summary: Type hints (PEP 484) support for the Sphinx autodoc extension License: MIT ++++++ python-sphinx-autodoc-typehints-system-object.inv.patch ++++++ --- /var/tmp/diff_new_pack.JEnhir/_old 2021-08-03 22:49:29.284442783 +0200 +++ /var/tmp/diff_new_pack.JEnhir/_new 2021-08-03 22:49:29.284442783 +0200 @@ -1,16 +1,10 @@ --- - tests/conftest.py | 13 ++----------- - 1 file changed, 2 insertions(+), 11 deletions(-) + tests/conftest.py | 12 ++---------- + 1 file changed, 2 insertions(+), 10 deletions(-) --- a/tests/conftest.py +++ b/tests/conftest.py -@@ -1,5 +1,4 @@ - import os --import sys - import pathlib - import shutil - -@@ -13,16 +12,8 @@ collect_ignore = ['roots'] +@@ -14,16 +14,8 @@ collect_ignore = ['roots'] @pytest.fixture(scope='session') def inv(pytestconfig): ++++++ sphinx-autodoc-typehints-1.11.0.tar.gz -> sphinx-autodoc-typehints-1.12.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/.github/ISSUE_TEMPLATE/bug_report.md new/sphinx-autodoc-typehints-1.12.0/.github/ISSUE_TEMPLATE/bug_report.md --- old/sphinx-autodoc-typehints-1.11.0/.github/ISSUE_TEMPLATE/bug_report.md 1970-01-01 01:00:00.000000000 +0100 +++ new/sphinx-autodoc-typehints-1.12.0/.github/ISSUE_TEMPLATE/bug_report.md 2021-04-15 02:21:18.000000000 +0200 @@ -0,0 +1,21 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Please provide a **minimal** reproducible example that developers can run to investigate the problem. +You can find help for creating such an example [here](https://stackoverflow.com/help/minimal-reproducible-example). + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Additional context** +Add any other context about the problem here. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/.github/ISSUE_TEMPLATE/feature_request.md new/sphinx-autodoc-typehints-1.12.0/.github/ISSUE_TEMPLATE/feature_request.md --- old/sphinx-autodoc-typehints-1.11.0/.github/ISSUE_TEMPLATE/feature_request.md 1970-01-01 01:00:00.000000000 +0100 +++ new/sphinx-autodoc-typehints-1.12.0/.github/ISSUE_TEMPLATE/feature_request.md 2021-04-15 02:21:18.000000000 +0200 @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: enhancement +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/.github/workflows/codeqa-test.yml new/sphinx-autodoc-typehints-1.12.0/.github/workflows/codeqa-test.yml --- old/sphinx-autodoc-typehints-1.11.0/.github/workflows/codeqa-test.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/sphinx-autodoc-typehints-1.12.0/.github/workflows/codeqa-test.yml 2021-04-15 02:21:18.000000000 +0200 @@ -0,0 +1,68 @@ +name: Python codeqa/test + +on: + push: + branches: [master] + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + - uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: pip-lint + - name: Install dependencies + run: pip install flake8 isort + - name: Run flake8 + run: flake8 sphinx_autodoc_typehints.py tests + - name: Run isort + run: isort -c sphinx_autodoc_typehints.py tests + + test: + needs: [lint] + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + python-version: [3.6, 3.7, 3.8, 3.9, 3.10.0-alpha.5] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: pip-test-${{ matrix.python-version }}-${{ matrix.os }} + - name: Install dependencies + run: pip install .[test,type_comments] coveralls + - name: Test with pytest + run: coverage run -m pytest + - name: Upload Coverage + run: coveralls --service=github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_FLAG_NAME: ${{ matrix.test-name }} + COVERALLS_PARALLEL: true + + coveralls: + name: Finish Coveralls + needs: test + runs-on: ubuntu-latest + container: python:3-slim + steps: + - name: Finished + run: | + pip install coveralls + coveralls --service=github --finish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/.github/workflows/publish.yml new/sphinx-autodoc-typehints-1.12.0/.github/workflows/publish.yml --- old/sphinx-autodoc-typehints-1.11.0/.github/workflows/publish.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/sphinx-autodoc-typehints-1.12.0/.github/workflows/publish.yml 2021-04-15 02:21:18.000000000 +0200 @@ -0,0 +1,27 @@ +name: Publish packages to PyPI + +on: + push: + tags: + - "[0-9]+.[0-9]+.[0-9]+" + - "[0-9]+.[0-9]+.[0-9]+[a-b][0-9]+" + - "[0-9]+.[0-9]+.[0-9]+rc[0-9]+" + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + - name: Install dependencies + run: pip install build + - name: Create packages + run: python -m build -s -w . + - name: Upload packages + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.pypi_password }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/.travis.yml new/sphinx-autodoc-typehints-1.12.0/.travis.yml --- old/sphinx-autodoc-typehints-1.11.0/.travis.yml 2020-06-21 08:33:11.000000000 +0200 +++ new/sphinx-autodoc-typehints-1.12.0/.travis.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,64 +0,0 @@ -dist: xenial -language: python -python: "3.6" - -stages: - - name: static analysis - - name: test - - name: deploy to pypi - if: type = push AND tag =~ ^\d+\.\d+\.\d+ - -jobs: - include: - - stage: static analysis - env: TOXENV=flake8 - - - stage: test - env: TOXENV=py35 - python: "3.5.2" - after_success: &after_success - - pip install coveralls - - coveralls - - - stage: test - env: TOXENV=py35 - python: "3.5" - after_success: *after_success - - - stage: test - env: TOXENV=py36 - python: "3.6" - after_success: *after_success - - - stage: test - env: TOXENV=py37 - python: "3.7" - after_success: *after_success - - - stage: test - env: TOXENV=py38 - python: "3.8" - after_success: *after_success - - - stage: deploy to pypi - install: skip - script: skip - deploy: - provider: pypi - user: agronholm - password: - secure: duaV12IvSrtlrjcqkbOToB0YTQkFRMM3SADKPVL4JapNYbhGCHsNgauAptnIZrTIFy3B2ZQH5QxOu1xapR3LHbwCrh9VV6QYTU1BFV8ju5gTcnCWcuN0Sr42LuwB3v5sCjijMrNIfo04ovhgJKCPfOiFV3bsXv+PSUm221qLixG8vHmoP2Vqhb+8+McV/JeMMjxfMv/XFb3fWoQwaspERVu/Xt4f/taJ7JFNOJBjYYwYY79mxE6TJOTypgnrgypO0YyqjrvVsjFNuCH3QeQYtDIcJRTekp/Oo9hiNt6T4nuf3X09F9vKhFuGXtpmdwjnIktQb2jkP4FSHGJ3z/6UJP7yPgMXaFezzih5WjBVuMwDu9HOo4EHE+0hgkL5aQfbFulF2moE7PGEqhTWZkEzxGKc/ds+YbfYGigrcpuCm+KvDtQHAUkrIa8mEw5wM5+QGiiBGEzxZ6ifsZzxADEoCNshU3r6rHBWlA4ze5Q0PFCC7Jns2uqe51+9qqBz+cGKjQafn+1DwGBIr/tZusx8cjRJpsvZ116Zq7viCfzBmxEt4yA5UPYmpljS7bBSJrbrXVRNZGmAm9oO5adI99MnrQsDdVMM3KoC0R3JOmiGaKuM573am57EZ6c/hKKqyLs4MS6WLkYbygNPq3N0bQG6JKtvVKGPB1xTA116Mve6cJc= - distributions: sdist bdist_wheel - on: - tags: true - -install: pip install tox - -script: tox - -env: - global: - - COVERALLS_PARALLEL=true - -notifications: - webhooks: https://coveralls.io/webhook diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/CHANGELOG.rst new/sphinx-autodoc-typehints-1.12.0/CHANGELOG.rst --- old/sphinx-autodoc-typehints-1.11.0/CHANGELOG.rst 2020-06-21 08:33:11.000000000 +0200 +++ new/sphinx-autodoc-typehints-1.12.0/CHANGELOG.rst 2021-04-15 02:21:18.000000000 +0200 @@ -1,224 +1,178 @@ -1.11.0 -====== +**1.12.0** -* Dropped support for Sphinx < 3.0 -* Added support for alternative parameter names (``arg``, ``argument``, ``parameter``) -* Fixed import path for Signature (PR by Matthew Treinish) -* Fixed ``TypeError`` when formatting a parametrized ``typing.IO`` annotation -* Fixed data class displaying a return type in its ``__init__()`` method +- Dropped Python 3.5 support +- Added the simplify_optional_unions config option (PR by tillhainbach) +- Fixed indentation of multiline strings (PR by Yuxin Wu) +**1.11.1** -1.10.3 -====== +- Changed formatting of ``None`` to point to the Python stdlib docs (PR by Dominic Davis-Foster) +- Updated special dataclass handling (PR by Lihu Ben-Ezri-Ravin) -* Fixed ``TypeError`` (or wrong rendered class name) when an annotation is a generic class that has - a ``name`` property +**1.11.0** +- Dropped support for Sphinx < 3.0 +- Added support for alternative parameter names (``arg``, ``argument``, ``parameter``) +- Fixed import path for Signature (PR by Matthew Treinish) +- Fixed ``TypeError`` when formatting a parametrized ``typing.IO`` annotation +- Fixed data class displaying a return type in its ``__init__()`` method -1.10.2 -====== +**1.10.3** -* Fixed inner classes missing their parent class name(s) when rendered +- Fixed ``TypeError`` (or wrong rendered class name) when an annotation is a generic class that has + a ``name`` property +**1.10.2** -1.10.1 -====== +- Fixed inner classes missing their parent class name(s) when rendered -* Fixed ``KeyError`` when encountering mocked annotations (``autodoc_mock_imports``) +**1.10.1** +- Fixed ``KeyError`` when encountering mocked annotations (``autodoc_mock_imports``) -1.10.0 -====== +**1.10.0** -* Rewrote the annotation formatting logic (fixes Python 3.5.2 compatibility regressions and an +- Rewrote the annotation formatting logic (fixes Python 3.5.2 compatibility regressions and an ``AttributeError`` regression introduced in v1.9.0) -* Fixed decorator classes not being processed as classes +- Fixed decorator classes not being processed as classes +**1.9.0** -1.9.0 -===== - -* Added support for typing_extensions_ -* Added the ``typehints_document_rtype`` option (PR by Simon-Martin Schr??der) -* Fixed metaclasses as annotations causing ``TypeError`` -* Fixed rendering of ``typing.Literal`` -* Fixed OSError when generating docs for SQLAlchemy mapped classes -* Fixed unparametrized generic classes being rendered with their type parameters +- Added support for typing_extensions_ +- Added the ``typehints_document_rtype`` option (PR by Simon-Martin Schr??der) +- Fixed metaclasses as annotations causing ``TypeError`` +- Fixed rendering of ``typing.Literal`` +- Fixed OSError when generating docs for SQLAlchemy mapped classes +- Fixed unparametrized generic classes being rendered with their type parameters (e.g. ``Dict[~KT, ~VT]``) .. _typing_extensions: https://pypi.org/project/typing-extensions/ +**1.8.0** -1.8.0 -===== - -* Fixed regression which caused ``TypeError`` or ``OSError`` when trying to set annotations due to +- Fixed regression which caused ``TypeError`` or ``OSError`` when trying to set annotations due to PR #87 -* Fixed unintentional mangling of annotation type names -* Added proper ``:py:data`` targets for ``NoReturn``, ``ClassVar`` and ``Tuple`` -* Added support for inline type comments (like ``(int, str) -> None``) (PR by Bern??t G??bor) -* Use the native AST parser for type comment support on Python 3.8+ - - -1.7.0 -===== - -* Dropped support for Python 3.4 -* Fixed unwrapped local functions causing errors (PR by Kimiyuki Onaka) -* Fixed ``AttributeError`` when documenting the ``__init__()`` method of a data class -* Added support for type hint comments (PR by Markus Unterwaditzer) -* Added flag for rendering classes with their fully qualified names (PR by Holly Becker) +- Fixed unintentional mangling of annotation type names +- Added proper ``:py:data`` targets for ``NoReturn``, ``ClassVar`` and ``Tuple`` +- Added support for inline type comments (like ``(int, str) -> None``) (PR by Bern??t G??bor) +- Use the native AST parser for type comment support on Python 3.8+ + +**1.7.0** + +- Dropped support for Python 3.4 +- Fixed unwrapped local functions causing errors (PR by Kimiyuki Onaka) +- Fixed ``AttributeError`` when documenting the ``__init__()`` method of a data class +- Added support for type hint comments (PR by Markus Unterwaditzer) +- Added flag for rendering classes with their fully qualified names (PR by Holly Becker) +**1.6.0** -1.6.0 -===== - -* Fixed ``TypeError`` when formatting annotations from a class that inherits from a concrete +- Fixed ``TypeError`` when formatting annotations from a class that inherits from a concrete generic type (report and tests by bpeake-illuscio) -* Added support for ``typing_extensions.Protocol`` (PR by Ian Good) -* Added support for ``typing.NewType`` (PR by George Leslie-Waksman) - +- Added support for ``typing_extensions.Protocol`` (PR by Ian Good) +- Added support for ``typing.NewType`` (PR by George Leslie-Waksman) -1.5.2 -===== +**1.5.2** -* Emit a warning instead of crashing when an unresolvable forward reference is encountered in type +- Emit a warning instead of crashing when an unresolvable forward reference is encountered in type annotations +**1.5.1** -1.5.1 -===== - -* Fixed escape characters in parameter default values getting lost during signature processing -* Replaced use of the ``config-inited`` event (which inadvertently required Sphinx 1.8) with the +- Fixed escape characters in parameter default values getting lost during signature processing +- Replaced use of the ``config-inited`` event (which inadvertently required Sphinx 1.8) with the ``builder-inited`` event +**1.5.0** -1.5.0 -===== - -* The setting of the ``typing.TYPECHECKING`` flag is now configurable using the +- The setting of the ``typing.TYPECHECKING`` flag is now configurable using the ``set_type_checking_flag`` option +**1.4.0** -1.4.0 -===== - -* The extension now sets ``typing.TYPECHECKING`` to ``True`` during setup to include conditional +- The extension now sets ``typing.TYPECHECKING`` to ``True`` during setup to include conditional imports which may be used in type annotations -* Fixed parameters with trailing underscores (PR by Daniel Knell) -* Fixed KeyError with private methods (PR by Benito Palacios S??nchez) -* Fixed deprecation warning about the use of formatargspec (PR by Y. Somda) -* The minimum Sphinx version is now v1.7.0 - - -1.3.1 -===== +- Fixed parameters with trailing underscores (PR by Daniel Knell) +- Fixed KeyError with private methods (PR by Benito Palacios S??nchez) +- Fixed deprecation warning about the use of formatargspec (PR by Y. Somda) +- The minimum Sphinx version is now v1.7.0 -* Fixed rendering of generic types outside the typing module (thanks to Tim Poterba for the PR) +**1.3.1** +- Fixed rendering of generic types outside the typing module (thanks to Tim Poterba for the PR) -1.3.0 -===== +**1.3.0** -* Fixed crash when processing docstrings from nested classes (thanks to dilyanpalauzov for the fix) -* Added support for Python 3.7 -* Dropped support for Python 3.5.0 and 3.5.1 +- Fixed crash when processing docstrings from nested classes (thanks to dilyanpalauzov for the fix) +- Added support for Python 3.7 +- Dropped support for Python 3.5.0 and 3.5.1 +**1.2.5** -1.2.5 -===== - -* Ensured that ``:rtype:`` doesn't get joined with a paragraph of text +- Ensured that ``:rtype:`` doesn't get joined with a paragraph of text (thanks to Bruce Merry for the PR) +**1.2.4** -1.2.4 -===== - -* Removed support for ``backports.typing`` as it has been removed from the PyPI -* Fixed first parameter being cut out from class methods and static methods +- Removed support for ``backports.typing`` as it has been removed from the PyPI +- Fixed first parameter being cut out from class methods and static methods (thanks to Josiah Wolf Oberholtzer for the PR) +**1.2.3** -1.2.3 -===== - -* Fixed `process_signature()` clobbering any explicitly overridden signatures from the docstring - +- Fixed `process_signature()` clobbering any explicitly overridden signatures from the docstring -1.2.2 -===== +**1.2.2** -* Explicitly prefix ``:class:``, ``:mod:`` et al with ``:py:``, in case ``py`` is not the default +- Explicitly prefix ``:class:``, ``:mod:`` et al with ``:py:``, in case ``py`` is not the default domain of the project (thanks Monty Taylor) +**1.2.1** -1.2.1 -===== - -* Fixed `ValueError` when `getargspec()` encounters a built-in function -* Fixed `AttributeError` when `Any` is combined with another type in a `Union` +- Fixed `ValueError` when `getargspec()` encounters a built-in function +- Fixed `AttributeError` when `Any` is combined with another type in a `Union` (thanks Davis Kirkendall) +**1.2.0** -1.2.0 -===== - -* Fixed compatibility with Python 3.6 and 3.5.3 -* Fixed ``NameError`` when processing signatures of wrapped functions with type hints -* Fixed handling of slotted classes with no ``__init__()`` method -* Fixed Sphinx warning about parallel reads -* Fixed return type being added to class docstring from its ``__init__()`` method +- Fixed compatibility with Python 3.6 and 3.5.3 +- Fixed ``NameError`` when processing signatures of wrapped functions with type hints +- Fixed handling of slotted classes with no ``__init__()`` method +- Fixed Sphinx warning about parallel reads +- Fixed return type being added to class docstring from its ``__init__()`` method (thanks to Manuel Krebber for the patch) -* Fixed return type hints of ``@property`` methods being omitted (thanks to pknight for the patch) -* Added a test suite (thanks Manuel Krebber) - - -1.1.0 -===== - -* Added proper support for ``typing.Tuple`` (pull request by Manuel Krebber) - - -1.0.6 -===== - -* Fixed wrong placement of ``:rtype:`` if a multi-line ``:param:`` or a ``:returns:`` is used - - -1.0.5 -===== +- Fixed return type hints of ``@property`` methods being omitted (thanks to pknight for the patch) +- Added a test suite (thanks Manuel Krebber) -* Fixed coroutine functions' signatures not being processed when using sphinxcontrib-asyncio +**1.1.0** +- Added proper support for ``typing.Tuple`` (pull request by Manuel Krebber) -1.0.4 -===== +**1.0.6** -* Fixed compatibility with Sphinx 1.4 +- Fixed wrong placement of ``:rtype:`` if a multi-line ``:param:`` or a ``:returns:`` is used +**1.0.5** -1.0.3 -===== +- Fixed coroutine functions' signatures not being processed when using sphinxcontrib-asyncio -* Fixed "self" parameter not being removed from exception class constructor signatures -* Fixed process_signature() erroneously removing the first argument of a static method +**1.0.4** +- Fixed compatibility with Sphinx 1.4 -1.0.2 -===== +**1.0.3** -* Fixed exception classes not being processed like normal classes +- Fixed "self" parameter not being removed from exception class constructor signatures +- Fixed process_signature() erroneously removing the first argument of a static method +**1.0.2** -1.0.1 -===== +- Fixed exception classes not being processed like normal classes -* Fixed errors caused by forward references not being looked up with the right globals +**1.0.1** +- Fixed errors caused by forward references not being looked up with the right globals -1.0.0 -===== +**1.0.0** -* Initial release +- Initial release diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/PKG-INFO new/sphinx-autodoc-typehints-1.12.0/PKG-INFO --- old/sphinx-autodoc-typehints-1.11.0/PKG-INFO 2020-06-21 08:33:27.000000000 +0200 +++ new/sphinx-autodoc-typehints-1.12.0/PKG-INFO 2021-04-15 02:21:26.990801300 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: sphinx-autodoc-typehints -Version: 1.11.0 +Version: 1.12.0 Summary: Type hints (PEP 484) support for the Sphinx autodoc extension Home-page: UNKNOWN Author: Alex Gr??nholm @@ -76,7 +76,13 @@ be able to add type info. * ``typehints_document_rtype`` (default: ``True``): If ``False``, never add an ``:rtype:`` directive. If ``True``, add the ``:rtype:`` directive if no existing ``:rtype:`` is found. - + * ``simplify_optional_unions`` (default: ``True``): If ``True``, optional parameters of type "Union[...]" + are simplified as being of type Union[..., None] in the resulting documention + (e.g. Optional[Union[A, B]] -> Union[A, B, None]). + If ``False``, the "Optional"-type is kept. + Note: If ``False``, **any** Union containing ``None`` will be displayed as Optional! + Note: If an optional parameter has only a single type (e.g Optional[A] or Union[A, None]), + it will **always** be displayed as Optional! How it works ------------ @@ -150,10 +156,11 @@ Classifier: Topic :: Documentation :: Sphinx Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 -Requires-Python: >=3.5.2 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 +Requires-Python: >=3.6 Provides-Extra: test Provides-Extra: type_comments diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/README.rst new/sphinx-autodoc-typehints-1.12.0/README.rst --- old/sphinx-autodoc-typehints-1.11.0/README.rst 2020-06-21 08:33:11.000000000 +0200 +++ new/sphinx-autodoc-typehints-1.12.0/README.rst 2021-04-15 02:21:18.000000000 +0200 @@ -65,7 +65,13 @@ be able to add type info. * ``typehints_document_rtype`` (default: ``True``): If ``False``, never add an ``:rtype:`` directive. If ``True``, add the ``:rtype:`` directive if no existing ``:rtype:`` is found. - +* ``simplify_optional_unions`` (default: ``True``): If ``True``, optional parameters of type "Union[...]" + are simplified as being of type Union[..., None] in the resulting documention + (e.g. Optional[Union[A, B]] -> Union[A, B, None]). + If ``False``, the "Optional"-type is kept. + Note: If ``False``, **any** Union containing ``None`` will be displayed as Optional! + Note: If an optional parameter has only a single type (e.g Optional[A] or Union[A, None]), + it will **always** be displayed as Optional! How it works ------------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/pre-commit-config.sample.yaml new/sphinx-autodoc-typehints-1.12.0/pre-commit-config.sample.yaml --- old/sphinx-autodoc-typehints-1.11.0/pre-commit-config.sample.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/sphinx-autodoc-typehints-1.12.0/pre-commit-config.sample.yaml 2021-04-15 02:21:18.000000000 +0200 @@ -0,0 +1,24 @@ +# This is the configuration file for pre-commit (https://pre-commit.com/). +# To use: +# * Install pre-commit (https://pre-commit.com/#installation) +# * Copy this file as ".pre-commit-config.yaml" +# * Run "pre-commit install". +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.4.0 + hooks: + - id: check-toml + - id: debug-statements + - id: end-of-file-fixer + - id: mixed-line-ending + args: ["--fix=lf"] + - id: trailing-whitespace +- repo: https://github.com/pre-commit/mirrors-autopep8 + rev: v1.5.6 + hooks: + - id: autopep8 +- repo: https://github.com/pycqa/isort + rev: 5.8.0 + hooks: + - id: isort + additional_dependencies: [toml] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/pyproject.toml new/sphinx-autodoc-typehints-1.12.0/pyproject.toml --- old/sphinx-autodoc-typehints-1.11.0/pyproject.toml 2020-06-21 08:33:11.000000000 +0200 +++ new/sphinx-autodoc-typehints-1.12.0/pyproject.toml 2021-04-15 02:21:18.000000000 +0200 @@ -5,3 +5,15 @@ "wheel >= 0.29.0", ] build-backend = 'setuptools.build_meta' + +[tool.isort] +skip_gitignore = true +line_length = 99 +multi_line_output = 4 + +[tool.autopep8] +max_line_length = 99 + +[tool.pytest.ini_options] +addopts = "-rsx --tb=short" +testpaths = ["tests"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/setup.cfg new/sphinx-autodoc-typehints-1.12.0/setup.cfg --- old/sphinx-autodoc-typehints-1.11.0/setup.cfg 2020-06-21 08:33:27.000000000 +0200 +++ new/sphinx-autodoc-typehints-1.12.0/setup.cfg 2021-04-15 02:21:26.990801300 +0200 @@ -18,14 +18,15 @@ Topic :: Documentation :: Sphinx Programming Language :: Python Programming Language :: Python :: 3 - Programming Language :: Python :: 3.5 Programming Language :: Python :: 3.6 Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 [options] py_modules = sphinx_autodoc_typehints -python_requires = >=3.5.2 +python_requires = >=3.6 install_requires = Sphinx >= 3.0 [options.extras_require] @@ -34,6 +35,7 @@ typing_extensions >= 3.5 dataclasses; python_version == "3.6" sphobjinv >= 2.0 + Sphinx >= 3.2.0 type_comments = typed_ast >= 1.4.0; python_version < "3.8" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/sphinx_autodoc_typehints.egg-info/PKG-INFO new/sphinx-autodoc-typehints-1.12.0/sphinx_autodoc_typehints.egg-info/PKG-INFO --- old/sphinx-autodoc-typehints-1.11.0/sphinx_autodoc_typehints.egg-info/PKG-INFO 2020-06-21 08:33:27.000000000 +0200 +++ new/sphinx-autodoc-typehints-1.12.0/sphinx_autodoc_typehints.egg-info/PKG-INFO 2021-04-15 02:21:26.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: sphinx-autodoc-typehints -Version: 1.11.0 +Version: 1.12.0 Summary: Type hints (PEP 484) support for the Sphinx autodoc extension Home-page: UNKNOWN Author: Alex Gr??nholm @@ -76,7 +76,13 @@ be able to add type info. * ``typehints_document_rtype`` (default: ``True``): If ``False``, never add an ``:rtype:`` directive. If ``True``, add the ``:rtype:`` directive if no existing ``:rtype:`` is found. - + * ``simplify_optional_unions`` (default: ``True``): If ``True``, optional parameters of type "Union[...]" + are simplified as being of type Union[..., None] in the resulting documention + (e.g. Optional[Union[A, B]] -> Union[A, B, None]). + If ``False``, the "Optional"-type is kept. + Note: If ``False``, **any** Union containing ``None`` will be displayed as Optional! + Note: If an optional parameter has only a single type (e.g Optional[A] or Union[A, None]), + it will **always** be displayed as Optional! How it works ------------ @@ -150,10 +156,11 @@ Classifier: Topic :: Documentation :: Sphinx Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 -Requires-Python: >=3.5.2 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 +Requires-Python: >=3.6 Provides-Extra: test Provides-Extra: type_comments diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/sphinx_autodoc_typehints.egg-info/SOURCES.txt new/sphinx-autodoc-typehints-1.12.0/sphinx_autodoc_typehints.egg-info/SOURCES.txt --- old/sphinx-autodoc-typehints-1.11.0/sphinx_autodoc_typehints.egg-info/SOURCES.txt 2020-06-21 08:33:27.000000000 +0200 +++ new/sphinx-autodoc-typehints-1.12.0/sphinx_autodoc_typehints.egg-info/SOURCES.txt 2021-04-15 02:21:26.000000000 +0200 @@ -1,13 +1,17 @@ .gitignore -.travis.yml CHANGELOG.rst LICENSE README.rst +pre-commit-config.sample.yaml pyproject.toml setup.cfg setup.py sphinx_autodoc_typehints.py tox.ini +.github/ISSUE_TEMPLATE/bug_report.md +.github/ISSUE_TEMPLATE/feature_request.md +.github/workflows/codeqa-test.yml +.github/workflows/publish.yml sphinx_autodoc_typehints.egg-info/PKG-INFO sphinx_autodoc_typehints.egg-info/SOURCES.txt sphinx_autodoc_typehints.egg-info/dependency_links.txt diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/sphinx_autodoc_typehints.egg-info/requires.txt new/sphinx-autodoc-typehints-1.12.0/sphinx_autodoc_typehints.egg-info/requires.txt --- old/sphinx-autodoc-typehints-1.11.0/sphinx_autodoc_typehints.egg-info/requires.txt 2020-06-21 08:33:27.000000000 +0200 +++ new/sphinx-autodoc-typehints-1.12.0/sphinx_autodoc_typehints.egg-info/requires.txt 2021-04-15 02:21:26.000000000 +0200 @@ -4,6 +4,7 @@ pytest>=3.1.0 typing_extensions>=3.5 sphobjinv>=2.0 +Sphinx>=3.2.0 [test:python_version == "3.6"] dataclasses diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/sphinx_autodoc_typehints.py new/sphinx-autodoc-typehints-1.12.0/sphinx_autodoc_typehints.py --- old/sphinx-autodoc-typehints-1.11.0/sphinx_autodoc_typehints.py 2020-06-21 08:33:11.000000000 +0200 +++ new/sphinx-autodoc-typehints-1.12.0/sphinx_autodoc_typehints.py 2021-04-15 02:21:18.000000000 +0200 @@ -2,7 +2,7 @@ import sys import textwrap import typing -from typing import get_type_hints, TypeVar, Any, AnyStr, Tuple +from typing import Any, AnyStr, Tuple, TypeVar, get_type_hints from sphinx.util import logging from sphinx.util.inspect import signature as Signature @@ -72,17 +72,6 @@ # Special cases if class_name in ('Pattern', 'Match') and hasattr(annotation, 'type_var'): # Python < 3.7 return annotation.type_var, - elif class_name == 'Callable' and hasattr(annotation, '__result__'): # Python < 3.5.3 - argtypes = (Ellipsis,) if annotation.__args__ is Ellipsis else annotation.__args__ - return argtypes + (annotation.__result__,) - elif class_name == 'Union' and hasattr(annotation, '__union_params__'): # Union on Python 3.5 - return annotation.__union_params__ - elif class_name == 'Tuple' and hasattr(annotation, '__tuple_params__'): # Tuple on Python 3.5 - params = annotation.__tuple_params__ - if getattr(annotation, '__tuple_use_ellipsis__', False): - params += (Ellipsis,) - - return params elif class_name == 'ClassVar' and hasattr(annotation, '__type__'): # ClassVar on Python < 3.7 return annotation.__type__, elif class_name == 'NewType' and hasattr(annotation, '__supertype__'): @@ -95,10 +84,12 @@ return getattr(annotation, '__args__', ()) -def format_annotation(annotation, fully_qualified: bool = False) -> str: +def format_annotation(annotation, + fully_qualified: bool = False, + simplify_optional_unions: bool = True) -> str: # Special cases if annotation is None or annotation is type(None): # noqa: E721 - return '``None``' + return ':py:obj:`None`' elif annotation is Ellipsis: return '...' @@ -114,7 +105,7 @@ class_name = get_annotation_class_name(annotation, module) args = get_annotation_args(annotation, module, class_name) except ValueError: - return str(annotation) + return str(annotation).strip("'") # Redirect all typing_extensions types to the stdlib typing module if module == 'typing_extensions': @@ -130,23 +121,72 @@ if full_name == 'typing.NewType': args_format = '\\(:py:data:`~{name}`, {{}})'.format(name=annotation.__name__) role = 'func' - elif full_name == 'typing.Union' and len(args) == 2 and type(None) in args: - full_name = 'typing.Optional' - args = tuple(x for x in args if x is not type(None)) # noqa: E721 + elif full_name == 'typing.Union' and type(None) in args: + if len(args) == 2: + full_name = 'typing.Optional' + args = tuple(x for x in args if x is not type(None)) # noqa: E721 + elif not simplify_optional_unions: + full_name = 'typing.Optional' + args_format = '\\[:py:data:`{prefix}typing.Union`\\[{{}}]]'.format(prefix=prefix) + args = tuple(x for x in args if x is not type(None)) # noqa: E721 elif full_name == 'typing.Callable' and args and args[0] is not ...: - formatted_args = '\\[\\[' + ', '.join(format_annotation(arg) for arg in args[:-1]) + ']' - formatted_args += ', ' + format_annotation(args[-1]) + ']' + formatted_args = '\\[\\[' + ', '.join( + format_annotation( + arg, simplify_optional_unions=simplify_optional_unions) + for arg in args[:-1]) + ']' + formatted_args += ', ' + format_annotation( + args[-1], simplify_optional_unions=simplify_optional_unions) + ']' elif full_name == 'typing.Literal': formatted_args = '\\[' + ', '.join(repr(arg) for arg in args) + ']' if args and not formatted_args: - formatted_args = args_format.format(', '.join(format_annotation(arg, fully_qualified) - for arg in args)) + formatted_args = args_format.format(', '.join( + format_annotation(arg, fully_qualified, simplify_optional_unions) + for arg in args)) return ':py:{role}:`{prefix}{full_name}`{formatted_args}'.format( role=role, prefix=prefix, full_name=full_name, formatted_args=formatted_args) +# reference: https://github.com/pytorch/pytorch/pull/46548/files +def normalize_source_lines(sourcelines: str) -> str: + """ + This helper function accepts a list of source lines. It finds the + indentation level of the function definition (`def`), then it indents + all lines in the function body to a point at or greater than that + level. This allows for comments and continued string literals that + are at a lower indentation than the rest of the code. + Arguments: + sourcelines: source code + Returns: + source lines that have been correctly aligned + """ + sourcelines = sourcelines.split("\n") + + def remove_prefix(text, prefix): + return text[text.startswith(prefix) and len(prefix):] + + # Find the line and line number containing the function definition + for i, l in enumerate(sourcelines): + if l.lstrip().startswith("def"): + idx = i + break + else: + return "\n".join(sourcelines) + fn_def = sourcelines[idx] + + # Get a string representing the amount of leading whitespace + whitespace = fn_def.split("def")[0] + + # Add this leading whitespace to all lines before and after the `def` + aligned_prefix = [whitespace + remove_prefix(s, whitespace) for s in sourcelines[:idx]] + aligned_suffix = [whitespace + remove_prefix(s, whitespace) for s in sourcelines[idx + 1:]] + + # Put it together again + aligned_prefix.append(fn_def) + return "\n".join(aligned_prefix + aligned_suffix) + + def process_signature(app, what: str, name: str, obj, options, signature, return_annotation): if not callable(obj): return @@ -165,8 +205,20 @@ for param in signature.parameters.values() ] - # The generated dataclass __init__() is weird and needs the second condition - if '<locals>' in obj.__qualname__ and not (what == 'method' and name.endswith('.__init__')): + # The generated dataclass __init__() and class are weird and need extra checks + # This helper function operates on the generated class and methods + # of a dataclass, not an instantiated dataclass object. As such, + # it cannot be replaced by a call to `dataclasses.is_dataclass()`. + def _is_dataclass(name: str, what: str, qualname: str) -> bool: + if what == 'method' and name.endswith('.__init__'): + # generated __init__() + return True + if what == 'class' and qualname.endswith('.__init__'): + # generated class + return True + return False + + if '<locals>' in obj.__qualname__ and not _is_dataclass(name, what, obj.__qualname__): logger.warning( 'Cannot treat a function defined as a local function: "%s" (use @functools.wraps)', name) @@ -257,7 +309,8 @@ return children[0] try: - obj_ast = ast.parse(textwrap.dedent(inspect.getsource(obj)), **parse_kwargs) + obj_ast = ast.parse(textwrap.dedent( + normalize_source_lines(inspect.getsource(obj))), **parse_kwargs) except (OSError, TypeError): return {} @@ -370,7 +423,9 @@ argname = '{}\\_'.format(argname[:-1]) formatted_annotation = format_annotation( - annotation, fully_qualified=app.config.typehints_fully_qualified) + annotation, + fully_qualified=app.config.typehints_fully_qualified, + simplify_optional_unions=app.config.simplify_optional_unions) searchfor = [':{} {}:'.format(field, argname) for field in ('param', 'parameter', 'arg', 'argument')] @@ -397,7 +452,9 @@ return formatted_annotation = format_annotation( - type_hints['return'], fully_qualified=app.config.typehints_fully_qualified) + type_hints['return'], fully_qualified=app.config.typehints_fully_qualified, + simplify_optional_unions=app.config.simplify_optional_unions + ) insert_index = len(lines) for i, line in enumerate(lines): @@ -427,6 +484,7 @@ app.add_config_value('always_document_param_types', False, 'html') app.add_config_value('typehints_fully_qualified', False, 'env') app.add_config_value('typehints_document_rtype', True, 'env') + app.add_config_value('simplify_optional_unions', True, 'env') app.connect('builder-inited', builder_ready) app.connect('autodoc-process-signature', process_signature) app.connect('autodoc-process-docstring', process_docstring) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/tests/conftest.py new/sphinx-autodoc-typehints-1.12.0/tests/conftest.py --- old/sphinx-autodoc-typehints-1.11.0/tests/conftest.py 2020-06-21 08:33:11.000000000 +0200 +++ new/sphinx-autodoc-typehints-1.12.0/tests/conftest.py 2021-04-15 02:21:18.000000000 +0200 @@ -1,7 +1,8 @@ import os -import sys import pathlib +import re import shutil +import sys import pytest from sphinx.testing.path import path @@ -42,3 +43,12 @@ @pytest.fixture def rootdir(): return path(os.path.dirname(__file__) or '.').abspath() / 'roots' + + +def pytest_ignore_collect(path, config): + version_re = re.compile(r'_py(\d)(\d)\.py$') + match = version_re.search(path.basename) + if match: + version = tuple(int(x) for x in match.groups()) + if sys.version_info < version: + return True diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/tests/roots/test-dummy/conf.py new/sphinx-autodoc-typehints-1.12.0/tests/roots/test-dummy/conf.py --- old/sphinx-autodoc-typehints-1.11.0/tests/roots/test-dummy/conf.py 2020-06-21 08:33:11.000000000 +0200 +++ new/sphinx-autodoc-typehints-1.12.0/tests/roots/test-dummy/conf.py 2021-04-15 02:21:18.000000000 +0200 @@ -1,7 +1,6 @@ import pathlib import sys - # Make dummy_module.py available for autodoc. sys.path.insert(0, str(pathlib.Path(__file__).parent)) @@ -12,4 +11,4 @@ 'sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinx_autodoc_typehints', - ] +] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/tests/roots/test-dummy/dummy_module.py new/sphinx-autodoc-typehints-1.12.0/tests/roots/test-dummy/dummy_module.py --- old/sphinx-autodoc-typehints-1.11.0/tests/roots/test-dummy/dummy_module.py 2020-06-21 08:33:11.000000000 +0200 +++ new/sphinx-autodoc-typehints-1.12.0/tests/roots/test-dummy/dummy_module.py 2021-04-15 02:21:18.000000000 +0200 @@ -1,13 +1,8 @@ import typing +from dataclasses import dataclass from mailbox import Mailbox from typing import Callable, Union -try: - from dataclasses import dataclass -except ImportError: - def dataclass(cls): - return cls - def get_local_function(): def wrapper(self) -> str: @@ -185,6 +180,16 @@ """ return 42 + def method_without_typehint(self, x): + """ + Method docstring. + """ + # test that multiline str can be correctly indented + multiline_str = """ +test +""" + return multiline_str + def function_with_typehint_comment_not_inline(x=None, *y, z, **kwargs): # type: (Union[str, bytes], *str, bytes, **int) -> None @@ -239,6 +244,8 @@ class DataClass: """Class docstring.""" + x: int + class Decorator: """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/tests/test_sphinx_autodoc_typehints.py new/sphinx-autodoc-typehints-1.12.0/tests/test_sphinx_autodoc_typehints.py --- old/sphinx-autodoc-typehints-1.11.0/tests/test_sphinx_autodoc_typehints.py 2020-06-21 08:33:11.000000000 +0200 +++ new/sphinx-autodoc-typehints-1.12.0/tests/test_sphinx_autodoc_typehints.py 2021-04-15 02:21:18.000000000 +0200 @@ -4,20 +4,15 @@ import textwrap import typing from typing import ( - Any, AnyStr, Callable, Dict, Generic, Mapping, NewType, Optional, Pattern, Match, Tuple, - TypeVar, Union, Type) + IO, Any, AnyStr, Callable, Dict, Generic, Mapping, Match, NewType, Optional, Pattern, Tuple, + Type, TypeVar, Union) import pytest import typing_extensions from sphinx_autodoc_typehints import ( - format_annotation, process_docstring, get_annotation_module, get_annotation_class_name, - get_annotation_args) - -try: - from typing import IO -except ImportError: - from typing.io import IO + format_annotation, get_annotation_args, get_annotation_class_name, get_annotation_module, + process_docstring) T = TypeVar('T') U = TypeVar('U', covariant=True) @@ -98,7 +93,7 @@ @pytest.mark.parametrize('annotation, expected_result', [ (str, ':py:class:`str`'), (int, ':py:class:`int`'), - (type(None), '``None``'), + (type(None), ':py:obj:`None`'), (type, ':py:class:`type`'), (Type, ':py:class:`~typing.Type`'), (Type[A], ':py:class:`~typing.Type`\\[:py:class:`~%s.A`]' % __name__), @@ -126,11 +121,15 @@ (Union, ':py:data:`~typing.Union`'), (Union[str, bool], ':py:data:`~typing.Union`\\[:py:class:`str`, ' ':py:class:`bool`]'), + (Union[str, bool, None], ':py:data:`~typing.Union`\\[:py:class:`str`, ' + ':py:class:`bool`, :py:obj:`None`]'), pytest.param(Union[str, Any], ':py:data:`~typing.Union`\\[:py:class:`str`, ' ':py:data:`~typing.Any`]', marks=pytest.mark.skipif((3, 5, 0) <= sys.version_info[:3] <= (3, 5, 2), reason='Union erases the str on 3.5.0 -> 3.5.2')), (Optional[str], ':py:data:`~typing.Optional`\\[:py:class:`str`]'), + (Optional[Union[str, bool]], ':py:data:`~typing.Union`\\[:py:class:`str`, ' + ':py:class:`bool`, :py:obj:`None`]'), (Callable, ':py:data:`~typing.Callable`'), (Callable[..., int], ':py:data:`~typing.Callable`\\[..., :py:class:`int`]'), (Callable[[int], int], ':py:data:`~typing.Callable`\\[\\[:py:class:`int`], ' @@ -138,7 +137,7 @@ (Callable[[int, str], bool], ':py:data:`~typing.Callable`\\[\\[:py:class:`int`, ' ':py:class:`str`], :py:class:`bool`]'), (Callable[[int, str], None], ':py:data:`~typing.Callable`\\[\\[:py:class:`int`, ' - ':py:class:`str`], ``None``]'), + ':py:class:`str`], :py:obj:`None`]'), (Callable[[T], T], ':py:data:`~typing.Callable`\\[\\[\\~T], \\~T]'), (Pattern, ':py:class:`~typing.Pattern`'), (Pattern[str], ':py:class:`~typing.Pattern`\\[:py:class:`str`]'), @@ -158,6 +157,27 @@ result = format_annotation(annotation) assert result == expected_result + # Test with the "simplify_optional_unions" flag turned off: + if re.match(r'^:py:data:`~typing\.Union`\\\[.*``None``.*\]', expected_result): + # strip None - argument and copy string to avoid conflicts with + # subsequent tests + expected_result_not_simplified = expected_result.replace(', ``None``', '') + # encapsulate Union in typing.Optional + expected_result_not_simplified = ':py:data:`~typing.Optional`\\[' + \ + expected_result_not_simplified + expected_result_not_simplified += ']' + assert format_annotation(annotation, simplify_optional_unions=False) == \ + expected_result_not_simplified + + # Test with the "fully_qualified" flag turned on + if 'typing' in expected_result_not_simplified: + expected_result_not_simplified = expected_result_not_simplified.replace('~typing', + 'typing') + assert format_annotation(annotation, + fully_qualified=True, + simplify_optional_unions=False) == \ + expected_result_not_simplified + # Test with the "fully_qualified" flag turned on if 'typing' in expected_result or __name__ in expected_result: expected_result = expected_result.replace('~typing', 'typing') @@ -223,10 +243,14 @@ assert 'Cannot resolve forward reference in type annotations of ' in warnings, warnings format_args = {} - if always_document_param_types: - format_args['undoc_params'] = '\n\n Parameters:\n **x** ("int") --' - else: - format_args['undoc_params'] = "" + for indentation_level in range(2): + key = f'undoc_params_{indentation_level}' + if always_document_param_types: + format_args[key] = textwrap.indent( + '\n\n Parameters:\n **x** ("int") --', ' ' * indentation_level + ) + else: + format_args[key] = '' text_path = pathlib.Path(app.srcdir) / '_build' / 'text' / 'index.txt' with text_path.open('r') as f: @@ -250,7 +274,7 @@ Inner class. - _InnerClass__dunder_inner_method(x) + __dunder_inner_method(x) Dunder inner method. @@ -270,7 +294,7 @@ Return type: "str" - _Class__dunder_method(x) + __dunder_method(x) Dunder method docstring. @@ -423,6 +447,10 @@ Return type: "int" + method_without_typehint(x) + + Method docstring. + dummy_module.function_with_typehint_comment_not_inline(x=None, *y, z, **kwargs) Function docstring. @@ -469,18 +497,18 @@ dummy_module.undocumented_function(x) - Hi{undoc_params} + Hi{undoc_params_0} Return type: "str" - class dummy_module.DataClass + class dummy_module.DataClass(x) - Class docstring. + Class docstring.{undoc_params_0} - __init__() + __init__(x) - Initialize self. See help(type(self)) for accurate signature. + Initialize self. See help(type(self)) for accurate signature.{undoc_params_1} @dummy_module.Decorator(func) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sphinx-autodoc-typehints-1.11.0/tox.ini new/sphinx-autodoc-typehints-1.12.0/tox.ini --- old/sphinx-autodoc-typehints-1.11.0/tox.ini 2020-06-21 08:33:11.000000000 +0200 +++ new/sphinx-autodoc-typehints-1.12.0/tox.ini 2021-04-15 02:21:18.000000000 +0200 @@ -1,6 +1,6 @@ [tox] minversion = 3.3.0 -envlist = py35, py36, py37, py38, flake8 +envlist = py36, py37, py38, py39, py310, flake8 skip_missing_interpreters = true isolated_build = true