Skip to content

Commit

Permalink
Add typing stubs to build, run mypy during tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tasssadar committed Jan 18, 2023
1 parent 72a8747 commit 7b6965d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"] },
)
File renamed without changes.
Empty file added src/python/typings/py.typed
Empty file.
14 changes: 14 additions & 0 deletions tests/python/test_typing_stub.py
Original file line number Diff line number Diff line change
@@ -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.")

0 comments on commit 7b6965d

Please sign in to comment.