diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index a8ee3ea8..37a75af4 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -64,7 +64,7 @@ jobs: ${{ startsWith(matrix.os, 'windows') && format('build\tests\cpp\{0}\yaramod_tests.exe', matrix.config) || 'build/tests/cpp/yaramod_tests' }} - name: Python Tests run: | - python -m pip install pytest + python -m pip install pytest mypy==0.991 pytest -v tests/python - name: Documentation if: ${{ startsWith(matrix.os, 'ubuntu') }} diff --git a/setup.py b/setup.py index 246e1000..c28d1a78 100644 --- a/setup.py +++ b/setup.py @@ -186,4 +186,7 @@ def parse_yaramod_version(): 'build_ext': BuildExtCommand }, ext_modules=[Extension(name='yaramod', sources=[])], + packages=["yaramod"], + package_dir = {'yaramod': 'src/python/typings'}, + package_data={ "yaramod": ["*.pyi", "py.typed"] }, ) diff --git a/src/python/typings/__init__.py b/src/python/typings/__init__.pyi similarity index 100% rename from src/python/typings/__init__.py rename to src/python/typings/__init__.pyi diff --git a/src/python/typings/py.typed b/src/python/typings/py.typed new file mode 100644 index 00000000..e69de29b diff --git a/tests/python/test_typing_stub.py b/tests/python/test_typing_stub.py new file mode 100644 index 00000000..835fedd5 --- /dev/null +++ b/tests/python/test_typing_stub.py @@ -0,0 +1,14 @@ +import unittest +import subprocess +import sys + + +class TypingStubTests(unittest.TestCase): + def test_mypy(self): + try: + import mypy + except ImportError: + self.skipTest("MyPy not installed.") + + code = subprocess.call(["python3", "-m", "mypy", "--strict", "./src/python/typings/"], stdout=sys.stdout, stderr=sys.stderr) + self.assertEqual(code, 0, "mypy finished with non-zero status, its error message should be above.")