Skip to content

Commit 80af5d4

Browse files
committed
CI: Bump min Python 3.7+ and update tests for Python 3.10
Fix #400 Thanks @tjni
1 parent b3a56d9 commit 80af5d4

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ jobs:
1111

1212
strategy:
1313
matrix:
14-
python-version: [3.6, 3.7]
14+
python-version: [3.7, 3.8, '3.10']
1515
include:
16-
- python-version: 3.8
16+
- python-version: 3.9
1717
test-type: lint
18-
- python-version: 3.8
18+
- python-version: 3.9
1919
test-type: docs
2020

2121
steps:

pdoc/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ def _formatannotation(annot):
12751275
`typing.Optional`, `nptyping.NDArray` and other types.
12761276
12771277
>>> _formatannotation(NewType('MyType', str))
1278-
'MyType'
1278+
'pdoc.MyType'
12791279
>>> _formatannotation(Optional[Tuple[Optional[int], None]])
12801280
'Optional[Tuple[Optional[int], None]]'
12811281
"""

pdoc/documentation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ modified templates into the `directories` list of the
353353

354354
Compatibility
355355
-------------
356-
`pdoc` requires Python 3.6+.
356+
`pdoc` requires Python 3.7+.
357357
The last version to support Python 2.x is [pdoc3 0.3.x].
358358

359359
[pdoc3 0.3.x]: https://pypi.org/project/pdoc3/0.3.13/

pdoc/test/__init__.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ class CliTest(unittest.TestCase):
126126
def setUp(self):
127127
pdoc.reset()
128128

129-
@unittest.skipIf(sys.version_info < (3, 7), 'pdoc._formatannotation fails on Py3.6')
129+
@unittest.skipIf(sys.version_info < (3, 10),
130+
'HACK: _formatannotation() changed return value in Py3.10')
130131
def test_project_doctests(self):
131132
doctests = doctest.testmod(pdoc)
132133
assert not doctests.failed and doctests.attempted, doctests
@@ -185,8 +186,12 @@ def test_html(self):
185186
'<object ',
186187
' class="ident">_private',
187188
' class="ident">_Private',
188-
'non_callable_routine',
189189
]
190+
if sys.version_info >= (3, 10):
191+
include_patterns.append('non_callable_routine')
192+
else:
193+
exclude_patterns.append('non_callable_routine')
194+
190195
package_files = {
191196
'': self.PUBLIC_FILES,
192197
'.subpkg2': [f for f in self.PUBLIC_FILES
@@ -356,8 +361,11 @@ def test_text(self):
356361
'_Private',
357362
'subprocess',
358363
'Hidden',
359-
'non_callable_routine',
360364
]
365+
if sys.version_info >= (3, 10):
366+
include_patterns.append('non_callable_routine')
367+
else:
368+
exclude_patterns.append('non_callable_routine')
361369

362370
with self.subTest(package=EXAMPLE_MODULE):
363371
with redirect_streams() as (stdout, _):
@@ -543,8 +551,9 @@ class C:
543551
self.assertEqual(doc.doc['vars_dont'].docstring, '')
544552
self.assertIn('integer', doc.doc['but_clss_have_doc'].docstring)
545553

554+
@unittest.skipIf(sys.version_info >= (3, 10), 'No builtin module "parser" in Py3.10')
546555
def test_builtin_methoddescriptors(self):
547-
import parser
556+
import parser # TODO: replace with another public binary builtin
548557
with self.assertWarns(UserWarning):
549558
c = pdoc.Class('STType', pdoc.Module(parser), parser.STType)
550559
self.assertIsInstance(c.doc['compile'], pdoc.Function)
@@ -906,9 +915,13 @@ def bug130_str_annotation(a: "str"):
906915
def bug253_newtype_annotation(a: CustomType):
907916
return
908917

918+
expected = CustomType.__name__
919+
if sys.version_info > (3, 10):
920+
expected = f'{__name__}.{CustomType.__name__}'
921+
909922
self.assertEqual(
910923
pdoc.Function('bug253', mod, bug253_newtype_annotation).params(annotate=True),
911-
['a:\N{NBSP}CustomType'])
924+
[f'a:\N{NBSP}{expected}'])
912925

913926
# typing.Callable bug
914927
def f(a: typing.Callable):

setup.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import sys
33
from setuptools import setup, find_packages
44

5-
if sys.version_info < (3, 6):
6-
sys.exit('ERROR: pdoc requires Python 3.6+')
5+
if sys.version_info < (3, 7):
6+
sys.exit('ERROR: pdoc requires Python 3.7+')
77

88

99
def _discover_tests():
@@ -58,5 +58,5 @@ def _discover_tests():
5858
'write_to': os.path.join('pdoc', '_version.py'),
5959
},
6060
test_suite="setup._discover_tests",
61-
python_requires='>= 3.6',
61+
python_requires='>= 3.7',
6262
)

0 commit comments

Comments
 (0)