Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable type hints #280

Merged
merged 2 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/280.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added type hints support.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ setup: .develop
.PHONY: lint
lint:
pre-commit run --all-files
# mypy aiojobs tests
mypy .


.PHONY: test
Expand Down
13 changes: 2 additions & 11 deletions aiojobs/_scheduler.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
1 change: 1 addition & 0 deletions aiojobs/py.typed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Placeholder
15 changes: 11 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,31 @@
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<major>\d+)"
r"\.(?P<minor>\d+)"
r"\.(?P<patch>\d+)"
r'(?P<tag>.*)?"$',
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 ------------------------------------------------
Expand Down Expand Up @@ -163,7 +170,7 @@

# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
latex_elements: Dict[str, str] = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ classifiers = [
"Framework :: AsyncIO",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
Expand Down