diff --git a/CHANGES/280.feature b/CHANGES/280.feature new file mode 100644 index 00000000..14141fe8 --- /dev/null +++ b/CHANGES/280.feature @@ -0,0 +1 @@ +Added type hints support. diff --git a/Makefile b/Makefile index 838eb2fb..f17cc99a 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ setup: .develop .PHONY: lint lint: pre-commit run --all-files - # mypy aiojobs tests + mypy . .PHONY: test diff --git a/aiojobs/_scheduler.py b/aiojobs/_scheduler.py index 28954c82..f5f8df93 100644 --- a/aiojobs/_scheduler.py +++ b/aiojobs/_scheduler.py @@ -1,20 +1,11 @@ import asyncio import sys +from collections.abc import Collection from ._job import Job -try: - from collections.abc import Collection -except ImportError: # pragma: no cover - # Python 3.5 has no Collection ABC class - from collections.abc import Container, Iterable, Sized - bases = Sized, Iterable, Container -else: # pragma: no cover - bases = (Collection,) - - -class Scheduler(*bases): +class Scheduler(Collection): def __init__(self, *, close_timeout, limit, pending_limit, exception_handler): if sys.version_info >= (3, 7): self._loop = loop = asyncio.get_running_loop() diff --git a/aiojobs/py.typed b/aiojobs/py.typed new file mode 100644 index 00000000..dcf2c804 --- /dev/null +++ b/aiojobs/py.typed @@ -0,0 +1 @@ +# Placeholder diff --git a/docs/conf.py b/docs/conf.py index 16e535a2..fccd79a5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -23,14 +23,16 @@ import codecs import os import re +from typing import Dict _docs_path = os.path.dirname(__file__) _version_path = os.path.abspath( os.path.join(_docs_path, "..", "aiojobs", "__init__.py") ) +_version_info = None with codecs.open(_version_path, "r", "latin1") as fp: try: - _version_info = re.search( + match = re.search( r'^__version__ = "' r"(?P\d+)" r"\.(?P\d+)" @@ -38,9 +40,14 @@ r'(?P.*)?"$', fp.read(), re.M, - ).groupdict() + ) + if match is not None: + _version_info = match.groupdict() except IndexError: - raise RuntimeError("Unable to determine version.") + pass + +if _version_info is None: + raise RuntimeError("Unable to determine version.") # -- General configuration ------------------------------------------------ @@ -163,7 +170,7 @@ # -- Options for LaTeX output --------------------------------------------- -latex_elements = { +latex_elements: Dict[str, str] = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper',