Skip to content

Commit

Permalink
Add type annotations to uritemplate
Browse files Browse the repository at this point in the history
Also include py.typed so other libraries using it can rely on the annotations
  • Loading branch information
sigmavirus24 committed Oct 13, 2021
1 parent df95fab commit 1084502
Show file tree
Hide file tree
Showing 16 changed files with 261 additions and 244 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.pyc
*.swp
docs/_build
docs/build
bin/
include/
lib/
Expand Down
9 changes: 6 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ repos:
- id: reorder-python-imports
args: [--application-directories, '.:src', --py36-plus]
- repo: https://github.com/psf/black
rev: 21.7b0
rev: 21.9b0
hooks:
- id: black
args: [--line-length=79]
- repo: https://github.com/asottile/pyupgrade
rev: v2.23.3
hooks:
Expand All @@ -26,8 +25,12 @@ repos:
rev: v0.910
hooks:
- id: mypy
exclude: ^(docs/|example-plugin/)
exclude: ^(docs/|tests/)
- repo: https://github.com/jorisroovers/gitlint
rev: v0.16.0
hooks:
- id: gitlint
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.18.0
hooks:
- id: setup-cfg-fmt
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog - uritemplate
=======================

4.1.0 - 2021-10-12
------------------

- Add type annotations to uritemplate and distribute them for others to use
- Update to a modern documentation theme as well

4.0.0 - 2021-10-10
------------------

Expand Down
130 changes: 0 additions & 130 deletions docs/Makefile

This file was deleted.

20 changes: 10 additions & 10 deletions docs/conf.py → docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
import os
import sys

# This environment variable makes decorators not decorate functions, so their
# signatures in the generated documentation are still correct
os.environ["GENERATING_DOCUMENTATION"] = "uritemplate"

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
Expand All @@ -29,7 +25,11 @@

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ["sphinx.ext.autodoc"]
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.coverage",
"sphinx.ext.doctest",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand All @@ -45,7 +45,7 @@

# General information about the project.
project = "uritemplate"
copyright = "2013 - Ian Cordasco"
copyright = "2013 - Ian Stapleton Cordasco"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -95,7 +95,7 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = "nature"
html_theme = "furo"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down Expand Up @@ -188,7 +188,7 @@
"index",
"uritemplate.tex",
"uritemplate Documentation",
"Ian Cordasco",
"Ian Stapleton Cordasco",
"manual",
),
]
Expand Down Expand Up @@ -226,7 +226,7 @@
"index",
"uritemplate",
"uritemplate Documentation",
["Ian Cordasco"],
["Ian Stapleton Cordasco"],
1,
)
]
Expand All @@ -244,7 +244,7 @@
"index",
"uritemplate",
"uritemplate Documentation",
"Ian Cordasco",
"Ian Stapleton Cordasco",
"uritemplate",
"Library to expand RFC6570 templated URIs",
"Miscellaneous",
Expand Down
19 changes: 10 additions & 9 deletions docs/index.rst → docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ API

.. module:: uritemplate

.. autofunction:: uritemplate.expand
.. autofunction:: uritemplate.api.expand

.. autofunction:: uritemplate.partial
.. autofunction:: uritemplate.api.partial

.. autofunction:: uritemplate.variables
.. autofunction:: uritemplate.api.variables

.. autoclass:: uritemplate.URITemplate
.. autoclass:: uritemplate.template.URITemplate
:members:

Implementation Details
Expand All @@ -72,10 +72,11 @@ For example::
t.variables
# => [URIVariable(/user)]

Users can interact with :class:`URIVariable` objects as they see fit, but
their API may change and are not guaranteed to be consistent across versions.
Code relying on methods defined on :class:`URIVariable` and other classes,
methods, and functions in this section may break in future releases.
Users can interact with :class:`~uritemplate.variable.URIVariable` objects as
they see fit, but their API may change and are not guaranteed to be consistent
across versions. Code relying on methods defined on
:class:`~uritemplate.variable.URIVariable` and other classes, methods, and
functions in this section may break in future releases.

.. autoclass:: uritemplate.template.URIVariable
.. autoclass:: uritemplate.variable.URIVariable
:members: expand
3 changes: 3 additions & 0 deletions docs/source/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sphinx>=1.3.0
furo
doc8
19 changes: 19 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[tool.black]
line-length = 78
target-version = ['py36']
safe = true
exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| build
| dist
)/
)
'''
32 changes: 18 additions & 14 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
[metadata]
name = uritemplate
version = attr: uritemplate.__version__
description = Implementation of RFC 6570 URI Templates
long_description = file: README.rst
long_description_content_type = text/x-rst
url = https://uritemplate.readthedocs.org
author = Ian Stapleton Cordasco
author_email = [email protected]
keywords = rfc 6570 uri template
license = BSD 3-Clause License or Apache License, Version 2.0
license_file = LICENSE
long_description = file:README.rst
long_description_content_type = text/x-rst
url = https://uritemplate.readthedocs.org
version = attr: uritemplate.__version__

classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved
License :: OSI Approved :: BSD License
License :: OSI Approved :: Apache Software License
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
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
Programming Language :: Python :: Implementation :: CPython

[bdist_wheel]
universal = 1
keywords = rfc 6570 uri template

[options]
python_requires = >= 3.6
include_package_data = True
packages = find:
python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*
include_package_data = True

[options.package_data]
; NOTE: This only affects sdists
. = LICENSE, LICENSE.APACHE, LICENSE.BSD, AUTHORS.rst, HISTORY.rst
uritemplate = py.typed

[bdist_wheel]
universal = 1

[mypy]
strict = True
17 changes: 17 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ commands = pytest {posargs}

[testenv:pep8]
deps =
black
flake8
mypy
commands =
black uritemplate tests setup.py
flake8 {posargs} uritemplate tests setup.py
mypy uritemplate

[testenv:release]
deps =
Expand All @@ -35,5 +39,18 @@ deps = pre-commit
commands =
pre-commit run --all-files --show-diff-on-failure

[testenv:docs]
deps = -rdocs/source/requirements.txt
commands =
doc8 docs/source
sphinx-build -E -W -c docs/source -b html docs/source docs/build/html

[testenv:serve-docs]
skip_install = true
changedir = docs/build/html
deps =
commands =
python -m http.server {posargs}

[flake8]
exclude = docs/
Loading

0 comments on commit 1084502

Please sign in to comment.