Skip to content

Commit

Permalink
CI: Bump min Python 3.7+ and update tests for Python 3.10
Browse files Browse the repository at this point in the history
Fix #400
Thanks @tjni
  • Loading branch information
kernc committed Oct 29, 2022
1 parent b3a56d9 commit 80af5d4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:

strategy:
matrix:
python-version: [3.6, 3.7]
python-version: [3.7, 3.8, '3.10']
include:
- python-version: 3.8
- python-version: 3.9
test-type: lint
- python-version: 3.8
- python-version: 3.9
test-type: docs

steps:
Expand Down
2 changes: 1 addition & 1 deletion pdoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ def _formatannotation(annot):
`typing.Optional`, `nptyping.NDArray` and other types.
>>> _formatannotation(NewType('MyType', str))
'MyType'
'pdoc.MyType'
>>> _formatannotation(Optional[Tuple[Optional[int], None]])
'Optional[Tuple[Optional[int], None]]'
"""
Expand Down
2 changes: 1 addition & 1 deletion pdoc/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ modified templates into the `directories` list of the

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

[pdoc3 0.3.x]: https://pypi.org/project/pdoc3/0.3.13/
Expand Down
23 changes: 18 additions & 5 deletions pdoc/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ class CliTest(unittest.TestCase):
def setUp(self):
pdoc.reset()

@unittest.skipIf(sys.version_info < (3, 7), 'pdoc._formatannotation fails on Py3.6')
@unittest.skipIf(sys.version_info < (3, 10),
'HACK: _formatannotation() changed return value in Py3.10')
def test_project_doctests(self):
doctests = doctest.testmod(pdoc)
assert not doctests.failed and doctests.attempted, doctests
Expand Down Expand Up @@ -185,8 +186,12 @@ def test_html(self):
'<object ',
' class="ident">_private',
' class="ident">_Private',
'non_callable_routine',
]
if sys.version_info >= (3, 10):
include_patterns.append('non_callable_routine')
else:
exclude_patterns.append('non_callable_routine')

package_files = {
'': self.PUBLIC_FILES,
'.subpkg2': [f for f in self.PUBLIC_FILES
Expand Down Expand Up @@ -356,8 +361,11 @@ def test_text(self):
'_Private',
'subprocess',
'Hidden',
'non_callable_routine',
]
if sys.version_info >= (3, 10):
include_patterns.append('non_callable_routine')
else:
exclude_patterns.append('non_callable_routine')

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

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

expected = CustomType.__name__
if sys.version_info > (3, 10):
expected = f'{__name__}.{CustomType.__name__}'

self.assertEqual(
pdoc.Function('bug253', mod, bug253_newtype_annotation).params(annotate=True),
['a:\N{NBSP}CustomType'])
[f'a:\N{NBSP}{expected}'])

# typing.Callable bug
def f(a: typing.Callable):
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import sys
from setuptools import setup, find_packages

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


def _discover_tests():
Expand Down Expand Up @@ -58,5 +58,5 @@ def _discover_tests():
'write_to': os.path.join('pdoc', '_version.py'),
},
test_suite="setup._discover_tests",
python_requires='>= 3.6',
python_requires='>= 3.7',
)

0 comments on commit 80af5d4

Please sign in to comment.