From 03bfae61bea69a6322c9580fd11ebe0418f9d0a2 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 29 Mar 2022 11:21:59 +0100 Subject: [PATCH] Declare vagrant package as typed --- .pre-commit-config.yaml | 6 ++++++ mypy.ini | 13 +++++++++++++ setup.cfg | 3 +++ vagrant/py.typed | 0 vagrant/test.py | 5 +++-- 5 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 mypy.ini create mode 100644 vagrant/py.typed diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8da9053..2c914b1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,6 +41,12 @@ repos: - flake8-2020>=1.6.1 - flake8-docstrings>=1.6.0 - flake8-pytest-style>=1.6.0 + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.931 + hooks: + - id: mypy + # empty args needed in order to match mypy cli behavior + # args: [--strict] - repo: https://github.com/pycqa/pylint rev: v2.12.2 hooks: diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 0000000..9c05db2 --- /dev/null +++ b/mypy.ini @@ -0,0 +1,13 @@ +[mypy] +python_version = 3.8 +color_output = True +error_summary = True +; disallow_untyped_calls = True +; disallow_untyped_defs = True +; disallow_any_generics = True +; disallow_any_unimported = True +; warn_redundant_casts = True +; warn_return_any = True +; warn_unused_configs = True +# site-packages is here to help vscode mypy integration getting confused +exclude = (build|test/local-content|site-packages) diff --git a/setup.cfg b/setup.cfg index f9912cc..3df9add 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,3 +40,6 @@ python_requires = >=3.8 [options.extras_require] test = pytest>=7.0.0 + +[options.package_data] +vagrant = py.typed diff --git a/vagrant/py.typed b/vagrant/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/vagrant/test.py b/vagrant/test.py index 86ad144..2287144 100644 --- a/vagrant/test.py +++ b/vagrant/test.py @@ -4,6 +4,7 @@ It also removes some of the boilerplate involved in writing tests that leverage vagrant boxes. """ +from typing import Dict, List from unittest import TestCase from vagrant import Vagrant, stderr_cm @@ -20,11 +21,11 @@ class VagrantTestCase(TestCase): will remain up. Defaults to False """ - vagrant_boxes = [] + vagrant_boxes: List[str] = [] vagrant_root = None restart_boxes = False - __initial_box_statuses = {} + __initial_box_statuses: Dict[str, str] = {} __cleanup_actions = { Vagrant.NOT_CREATED: "destroy", Vagrant.POWEROFF: "halt",