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

feat: add 'py.typed' declaration #119

Merged
merged 3 commits into from
Dec 22, 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
16 changes: 16 additions & 0 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ on:

jobs:

mypy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.6"
- name: Install nox
run: |
python -m ensurepip
python -m pip install nox
- name: Run mypy
run: |
nox -s mypy

build-wheels-linux:
name: ${{ matrix.os }}
strategy:
Expand Down
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[mypy]
python_version = 3.6
exclude = tests/unit/resources/
12 changes: 12 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,15 @@ def check(session):
# Run py.test against the unit tests.
session.run("py.test", "tests")
session.run("python", f"{HERE}/scripts/check_crc32c_extension.py", *session.posargs)


@nox.session(python="3.6")
def mypy(session):
"""Verify type hints are mypy compatible."""
session.install("-e", ".")
session.install(
"mypy",
"types-mock",
"types-setuptools",
)
session.run("mypy", "src/google_crc32c/", "tests/")
2 changes: 1 addition & 1 deletion src/google_crc32c/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from google_crc32c import cext as impl
implementation = "c"
except ImportError as exc:
from google_crc32c import python as impl
from google_crc32c import python as impl # type: ignore
warnings.warn(_SLOW_CRC32C_WARNING, RuntimeWarning)
implementation = "python"

Expand Down
6 changes: 3 additions & 3 deletions src/google_crc32c/cext.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

# NOTE: ``__config__`` **must** be the first import because it (may)
# modify the search path used to locate shared libraries.
import google_crc32c.__config__
from google_crc32c._crc32c import extend
from google_crc32c._crc32c import value
import google_crc32c.__config__ # type: ignore
from google_crc32c._crc32c import extend # type: ignore
from google_crc32c._crc32c import value # type: ignore
from google_crc32c._checksum import CommonChecksum


Expand Down
2 changes: 2 additions & 0 deletions src/google_crc32c/py.typed
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Marker file for PEP 561.
# The google_crc32c package uses inline types.
2 changes: 1 addition & 1 deletion tests/test___init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import itertools
from unittest import mock

import pytest
import pytest # type: ignore

import google_crc32c

Expand Down