From 36e1105890e216db8ee955f27280ac7d8f97a508dd2a16f1a3ef71a9f72e625f Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Thu, 5 May 2022 10:40:05 +0000 Subject: [PATCH 1/5] Accepting request 975167 from home:mcepl:branches:devel:languages:python - Upgrade to 1.18.1: - Fix mocked module import not working when used as guarded import - Support and require nptyping>=2 - Handle UnionType - Mark it as requiring nptyping<2 - Add typehints_use_rtype option - Handles TypeError when getting source code via inspect - Add support for type subscriptions with multiple elements, where one or more elements are tuples; e.g., nptyping.NDArray[(Any, ...), nptyping.Float] - Fix bug for arbitrary types accepting singleton subscriptions; e.g., nptyping.Float[64] - Resolve forward references - Expand and better handle TypeVar - Add intershpinx reference link for ... to Ellipsis (as is just an alias) - Prevents reaching inner blocks that contains if TYPE_CHECKING - Log a warning instead of crashing when a type guard import fails to resolve - When resolving type guard imports if the target module does not have source code (such is the case for C-extension modules) do nothing instead of crashing - Fix fully_qualified should be typehints_fully_qualified - Resolve type guard imports before evaluating annotations for objects - Remove set_type_checking_flag flag as this is now done by default - Fix crash when the inspect module returns an invalid python syntax source - Made formatting function configurable using the option typehints_formatter - Fixed normalize_source_lines() messing with the indentation of methods with decorators that have parameters starting with def. - Handle ValueError or TypeError being raised when signature of an object cannot be determined - Fix KeyError being thrown when argument is not documented (e.g. cls argument for class methods, and self for methods) - Added typehints_defaults config option allowing to automatically annotate parameter defaults. - Fixed NewType inserts a reference as first argument instead of a string - Dropped Python 3.6 support - Python 3.10 support - Normalize async functions properly - Allow py310 style annotations (PEP-563) OBS-URL: https://build.opensuse.org/request/show/975167 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-sphinx-autodoc-typehints?expand=0&rev=25 --- ...-autodoc-typehints-system-object.inv.patch | 15 +++--- python-sphinx-autodoc-typehints.changes | 51 +++++++++++++++++++ python-sphinx-autodoc-typehints.spec | 13 +++-- sphinx-autodoc-typehints-1.12.0.tar.gz | 3 -- sphinx_autodoc_typehints-1.18.1.tar.gz | 3 ++ 5 files changed, 68 insertions(+), 17 deletions(-) delete mode 100644 sphinx-autodoc-typehints-1.12.0.tar.gz create mode 100644 sphinx_autodoc_typehints-1.18.1.tar.gz diff --git a/python-sphinx-autodoc-typehints-system-object.inv.patch b/python-sphinx-autodoc-typehints-system-object.inv.patch index c8d5621..9bf2de0 100644 --- a/python-sphinx-autodoc-typehints-system-object.inv.patch +++ b/python-sphinx-autodoc-typehints-system-object.inv.patch @@ -1,20 +1,21 @@ --- - tests/conftest.py | 12 ++---------- - 1 file changed, 2 insertions(+), 10 deletions(-) + tests/conftest.py | 13 ++----------- + 1 file changed, 2 insertions(+), 11 deletions(-) --- a/tests/conftest.py +++ b/tests/conftest.py -@@ -14,16 +14,8 @@ collect_ignore = ['roots'] +@@ -18,17 +18,8 @@ collect_ignore = ["roots"] - @pytest.fixture(scope='session') - def inv(pytestconfig): -- cache_path = 'python{v.major}.{v.minor}/objects.inv'.format(v=sys.version_info) + @pytest.fixture(scope="session") + def inv(pytestconfig: Config) -> Inventory: +- cache_path = f"python{sys.version_info.major}.{sys.version_info.minor}/objects.inv" +- assert pytestconfig.cache is not None - inv_dict = pytestconfig.cache.get(cache_path, None) - if inv_dict is not None: - return Inventory(inv_dict) - - print("Downloading objects.inv") -- url = 'https://docs.python.org/{v.major}.{v.minor}/objects.inv'.format(v=sys.version_info) +- url = "https://docs.python.org/{v.major}.{v.minor}/objects.inv".format(v=sys.version_info) - inv = Inventory(url=url) - pytestconfig.cache.set(cache_path, inv.json_dict()) - return inv diff --git a/python-sphinx-autodoc-typehints.changes b/python-sphinx-autodoc-typehints.changes index e6b7452..16a435e 100644 --- a/python-sphinx-autodoc-typehints.changes +++ b/python-sphinx-autodoc-typehints.changes @@ -1,3 +1,54 @@ +------------------------------------------------------------------- +Thu May 5 05:35:05 UTC 2022 - Matej Cepl + +- Upgrade to 1.18.1: + - Fix mocked module import not working when used as guarded + import + - Support and require nptyping>=2 + - Handle UnionType + - Mark it as requiring nptyping<2 + - Add typehints_use_rtype option + - Handles TypeError when getting source code via inspect + - Add support for type subscriptions with multiple elements, + where one or more elements are tuples; e.g., + nptyping.NDArray[(Any, ...), nptyping.Float] + - Fix bug for arbitrary types accepting singleton + subscriptions; e.g., nptyping.Float[64] + - Resolve forward references + - Expand and better handle TypeVar + - Add intershpinx reference link for ... to Ellipsis (as is + just an alias) + - Prevents reaching inner blocks that contains if TYPE_CHECKING + - Log a warning instead of crashing when a type guard import + fails to resolve + - When resolving type guard imports if the target module does + not have source code (such is the case for C-extension + modules) do nothing instead of crashing + - Fix fully_qualified should be typehints_fully_qualified + - Resolve type guard imports before evaluating annotations for + objects + - Remove set_type_checking_flag flag as this is now done by + default + - Fix crash when the inspect module returns an invalid python + syntax source + - Made formatting function configurable using the option + typehints_formatter + - Fixed normalize_source_lines() messing with the indentation + of methods with decorators that have parameters starting with + def. + - Handle ValueError or TypeError being raised when signature of + an object cannot be determined + - Fix KeyError being thrown when argument is not documented + (e.g. cls argument for class methods, and self for methods) + - Added typehints_defaults config option allowing to + automatically annotate parameter defaults. + - Fixed NewType inserts a reference as first argument instead + of a string + - Dropped Python 3.6 support + - Python 3.10 support + - Normalize async functions properly + - Allow py310 style annotations (PEP-563) + ------------------------------------------------------------------- Mon Dec 27 17:20:01 UTC 2021 - Ben Greiner diff --git a/python-sphinx-autodoc-typehints.spec b/python-sphinx-autodoc-typehints.spec index 5ab818c..2e99cc0 100644 --- a/python-sphinx-autodoc-typehints.spec +++ b/python-sphinx-autodoc-typehints.spec @@ -1,7 +1,7 @@ # # spec file for package python-sphinx-autodoc-typehints # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,17 +18,16 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 -%define skip_python310 1 Name: python-sphinx-autodoc-typehints -Version: 1.12.0 +Version: 1.18.1 Release: 0 Summary: Type hints (PEP 484) support for the Sphinx autodoc extension License: MIT Group: Development/Languages/Python URL: https://github.com/agronholm/sphinx-autodoc-typehints -Source: https://files.pythonhosted.org/packages/source/s/sphinx-autodoc-typehints/sphinx-autodoc-typehints-%{version}.tar.gz -# PATCH-FIX-UPSTREAM python-sphinx-autodoc-typehints-system-object.inv.patch gh#agronholm/sphinx-autodoc-typehints#174 mcepl@suse.com -# skip network tests +Source: https://files.pythonhosted.org/packages/source/s/sphinx-autodoc-typehints/sphinx_autodoc_typehints-%{version}.tar.gz +# PATCH-FIX-OPENSUSE python-sphinx-autodoc-typehints-system-object.inv.patch gh#agronholm/sphinx-autodoc-typehints#174 mcepl@suse.com +# Don't download inventory from the Internet, but use the local one. Patch0: python-sphinx-autodoc-typehints-system-object.inv.patch BuildRequires: %{python_module setuptools >= 36.2.7} BuildRequires: %{python_module setuptools_scm >= 1.7.0} @@ -52,7 +51,7 @@ This is a Sphinx extension which allows to use Python 3 annotations for document and return value types of functions. %prep -%autosetup -p1 -n sphinx-autodoc-typehints-%{version} +%autosetup -p1 -n sphinx_autodoc_typehints-%{version} %build %python_build diff --git a/sphinx-autodoc-typehints-1.12.0.tar.gz b/sphinx-autodoc-typehints-1.12.0.tar.gz deleted file mode 100644 index eb50061..0000000 --- a/sphinx-autodoc-typehints-1.12.0.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:193617d9dbe0847281b1399d369e74e34cd959c82e02c7efde077fca908a9f52 -size 19494 diff --git a/sphinx_autodoc_typehints-1.18.1.tar.gz b/sphinx_autodoc_typehints-1.18.1.tar.gz new file mode 100644 index 0000000..2c3d9ec --- /dev/null +++ b/sphinx_autodoc_typehints-1.18.1.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:07631c5f0c6641e5ba27143494aefc657e029bed3982138d659250e617f6f929 +size 31198 From ce57ddbe0890130f2e74322e4eb7c3827208c281d3461f0d5410d095967d128a Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 9 May 2022 14:05:14 +0000 Subject: [PATCH 2/5] Fix SPEC OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-sphinx-autodoc-typehints?expand=0&rev=26 --- python-sphinx-autodoc-typehints.spec | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python-sphinx-autodoc-typehints.spec b/python-sphinx-autodoc-typehints.spec index 2e99cc0..b27666f 100644 --- a/python-sphinx-autodoc-typehints.spec +++ b/python-sphinx-autodoc-typehints.spec @@ -39,6 +39,7 @@ BuildArch: noarch # SECTION tests BuildRequires: %{python_module Sphinx >= 1.7} BuildRequires: %{python_module doc} +BuildRequires: %{python_module nptyping} BuildRequires: %{python_module pathlib} BuildRequires: %{python_module pytest} BuildRequires: %{python_module sphobjinv} @@ -63,11 +64,12 @@ and return value types of functions. %check # test_sphinx_output -- too depenedent on sphinx version available -%pytest -k 'not test_sphinx_output' +# gh#tox-dev/sphinx-autodoc-typehints#229 +%pytest -k 'not (test_sphinx_output or test_format_annotation)' %files %{python_files} %{python_sitelib}/* %license LICENSE -%doc README.rst CHANGELOG.rst +%doc README.md CHANGELOG.md %changelog From aa4b62857e9ed43d1192f5a73892e5aa8898e8f46f73715c3c481ca4a06b4ab4 Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Mon, 9 May 2022 14:09:48 +0000 Subject: [PATCH 3/5] Fix SPEC OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-sphinx-autodoc-typehints?expand=0&rev=27 --- python-sphinx-autodoc-typehints.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python-sphinx-autodoc-typehints.spec b/python-sphinx-autodoc-typehints.spec index b27666f..1065af1 100644 --- a/python-sphinx-autodoc-typehints.spec +++ b/python-sphinx-autodoc-typehints.spec @@ -18,6 +18,8 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 +%define modname sphinx_autodoc_typehints + Name: python-sphinx-autodoc-typehints Version: 1.18.1 Release: 0 @@ -68,8 +70,9 @@ and return value types of functions. %pytest -k 'not (test_sphinx_output or test_format_annotation)' %files %{python_files} -%{python_sitelib}/* %license LICENSE %doc README.md CHANGELOG.md +%{python_sitelib}/%{modname}-%{version}*-info +%{python_sitelib}/%{modname} %changelog From fe370c270756bb4c24ccf069116da9dc5bd6643a5c638c27502cee92724e9a9a Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Wed, 11 May 2022 10:08:49 +0000 Subject: [PATCH 4/5] - Switch to multibuild to break build cycles. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-sphinx-autodoc-typehints?expand=0&rev=28 --- _multibuild | 4 ++++ python-sphinx-autodoc-typehints.changes | 5 +++++ python-sphinx-autodoc-typehints.spec | 23 +++++++++++++++++++---- 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 _multibuild diff --git a/_multibuild b/_multibuild new file mode 100644 index 0000000..6222fa7 --- /dev/null +++ b/_multibuild @@ -0,0 +1,4 @@ + + test + wheel + diff --git a/python-sphinx-autodoc-typehints.changes b/python-sphinx-autodoc-typehints.changes index 16a435e..de17502 100644 --- a/python-sphinx-autodoc-typehints.changes +++ b/python-sphinx-autodoc-typehints.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Wed May 11 10:08:38 UTC 2022 - Matej Cepl + +- Switch to multibuild to break build cycles. + ------------------------------------------------------------------- Thu May 5 05:35:05 UTC 2022 - Matej Cepl diff --git a/python-sphinx-autodoc-typehints.spec b/python-sphinx-autodoc-typehints.spec index 1065af1..4543240 100644 --- a/python-sphinx-autodoc-typehints.spec +++ b/python-sphinx-autodoc-typehints.spec @@ -1,5 +1,5 @@ # -# spec file for package python-sphinx-autodoc-typehints +# spec file # # Copyright (c) 2022 SUSE LLC # @@ -19,8 +19,15 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 %define modname sphinx_autodoc_typehints - -Name: python-sphinx-autodoc-typehints +%global flavor @BUILD_FLAVOR@%{nil} +%if "%{flavor}" == "test" +%define psuffix -test +%bcond_without test +%else +%define psuffix %{nil} +%bcond_with test +%endif +Name: python-sphinx-autodoc-typehints%{psuffix} Version: 1.18.1 Release: 0 Summary: Type hints (PEP 484) support for the Sphinx autodoc extension @@ -36,8 +43,8 @@ BuildRequires: %{python_module setuptools_scm >= 1.7.0} BuildRequires: fdupes BuildRequires: python-rpm-macros Requires: python-Sphinx >= 1.7 -Requires: python-typing_extensions BuildArch: noarch +%if %{with test} # SECTION tests BuildRequires: %{python_module Sphinx >= 1.7} BuildRequires: %{python_module doc} @@ -46,6 +53,7 @@ BuildRequires: %{python_module pathlib} BuildRequires: %{python_module pytest} BuildRequires: %{python_module sphobjinv} BuildRequires: %{python_module typing_extensions} +%endif # /SECTION %python_subpackages @@ -61,18 +69,25 @@ and return value types of functions. %python_expand sed -i -e 's/@PYTHON_VERSION@/%{$python_version}/' tests/conftest.py %install +%if %{without test} %python_install %python_expand %fdupes %{buildroot}%{$python_sitelib} +%endif %check +export PYTHONPATH=./src +%if %{with test} # test_sphinx_output -- too depenedent on sphinx version available # gh#tox-dev/sphinx-autodoc-typehints#229 %pytest -k 'not (test_sphinx_output or test_format_annotation)' +%endif +%if %{without test} %files %{python_files} %license LICENSE %doc README.md CHANGELOG.md %{python_sitelib}/%{modname}-%{version}*-info %{python_sitelib}/%{modname} +%endif %changelog From a8c2cd2e2d0264f405aebfea08297205bc766ca978d372df70701bcdb8e9b56a Mon Sep 17 00:00:00 2001 From: Matej Cepl Date: Wed, 11 May 2022 10:10:34 +0000 Subject: [PATCH 5/5] Too much OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-sphinx-autodoc-typehints?expand=0&rev=29 --- _multibuild | 1 - 1 file changed, 1 deletion(-) diff --git a/_multibuild b/_multibuild index 6222fa7..fcc7b97 100644 --- a/_multibuild +++ b/_multibuild @@ -1,4 +1,3 @@ test - wheel