Skip to content

Commit

Permalink
Merge pull request #407 from Daverball/mypy
Browse files Browse the repository at this point in the history
Adds type hints to public API.
  • Loading branch information
malthe authored Jan 9, 2024
2 parents f98b28e + 219cbdf commit 8ffa8e1
Show file tree
Hide file tree
Showing 28 changed files with 1,024 additions and 511 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ jobs:
config:
# [Python version, tox env]
- ["3.9", "lint"]
- ["3.8", "py38"]
- ["3.9", "py39"]
- ["3.10", "py310"]
- ["3.11", "py311"]
Expand All @@ -42,6 +41,7 @@ jobs:
- ["pypy-3.9", "pypy3"]
- ["3.9", "docs"]
- ["3.9", "coverage"]
- ["3.12", "mypy"]

runs-on: ${{ matrix.os[1] }}
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
.eggs/
.installed.cfg
.mr.developer.cfg
.mypy_cache/
.tox/
.vscode/
__pycache__/
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Chameleon is an HTML/XML template engine for `Python
<http://www.python.org>`_. It uses the *page templates* language.

You can use it in any Python application with just about any
version of Python (3.8+ and up, plus `pypy 3
version of Python (3.9+ and up, plus `pypy 3
<http://pypy.org>`_).

Visit the `documentation <https://chameleon.readthedocs.io/en/latest/>`_
Expand Down
30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[build-system]
requires = ["setuptools>=42", "wheel"]
build-backend = "setuptools.build_meta"

[tool.mypy]
mypy_path = "$MYPY_CONFIG_FILE_DIR/src"
# we may want to include tests eventually
exclude = "/tests/"
follow_imports = "silent"

[[tool.mypy.overrides]]
# strict config for fully typed modules and public API
module = [
"chameleon.exc.*",
"chameleon.utils.*",
"chameleon.zpt.loader.*",
"chameleon.zpt.template.*",
]
disallow_any_unimported = true
disallow_any_generics = true
disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_defs = true
disallow_incomplete_defs = true
disallow_untyped_decorators = true
warn_unused_ignores = true

[[tool.mypy.overrides]]
module = ["zope.*"]
ignore_missing_imports = true
10 changes: 5 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ universal = 0

[flake8]
doctests = 1
extend-select = TC1
# F401 imported but unused
per-file-ignores =
src/chameleon/__init__.py: F401
Expand All @@ -18,11 +19,10 @@ ignore =
[isort]
force_single_line = True
combine_as_imports = True
sections = FUTURE,STDLIB,THIRDPARTY,ZOPE,FIRSTPARTY,LOCALFOLDER
known_third_party = six, docutils, pkg_resources, pytz
known_zope =
known_first_party =
default_section = ZOPE
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
known_first_party = chameleon
extra_standard_library = _typeshed, typing_extensions
default_section = THIRDPARTY
line_length = 79
lines_after_imports = 2

Expand Down
12 changes: 7 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
README = ''
CHANGES = ''

install_requires = [
'importlib-metadata;python_version<"3.10"',
'importlib-resources;python_version<"3.9"']
install_requires = ['importlib-metadata;python_version<"3.10"']


class Benchmark(test):
Expand Down Expand Up @@ -49,7 +47,6 @@ def run_tests(self):
"Intended Audience :: Developers",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -69,7 +66,12 @@ def run_tests(self):
packages=find_packages('src'),
package_dir={'': 'src'},
include_package_data=True,
python_requires='>=3.8',
package_data={
'chameleon': [
'py.typed',
],
},
python_requires='>=3.9',
install_requires=install_requires,
extras_require={
'docs': {
Expand Down
Loading

0 comments on commit 8ffa8e1

Please sign in to comment.