[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 22/46] qapi: establish mypy type-checking baseline
From: |
John Snow |
Subject: |
[PATCH v4 22/46] qapi: establish mypy type-checking baseline |
Date: |
Wed, 30 Sep 2020 00:31:26 -0400 |
Fix two very minor issues, and then establish a mypy type-checking
baseline.
Like pylint, this should be run from the folder above:
> mypy --config-file=qapi/mypy.ini qapi/
This is designed and tested for mypy 0.770 or greater.
Signed-off-by: John Snow <jsnow@redhat.com>
Tested-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Tested-by: Cleber Rosa <crosa@redhat.com>
---
scripts/qapi/mypy.ini | 60 ++++++++++++++++++++++++++++++++++++++++++
scripts/qapi/schema.py | 3 ++-
2 files changed, 62 insertions(+), 1 deletion(-)
create mode 100644 scripts/qapi/mypy.ini
diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini
new file mode 100644
index 00000000000..00fac15dc6e
--- /dev/null
+++ b/scripts/qapi/mypy.ini
@@ -0,0 +1,60 @@
+[mypy]
+strict = True
+strict_optional = False
+disallow_untyped_calls = False
+python_version = 3.6
+
+[mypy-qapi.commands]
+disallow_untyped_defs = False
+disallow_incomplete_defs = False
+check_untyped_defs = False
+
+[mypy-qapi.error]
+disallow_untyped_defs = False
+disallow_incomplete_defs = False
+check_untyped_defs = False
+
+[mypy-qapi.events]
+disallow_untyped_defs = False
+disallow_incomplete_defs = False
+check_untyped_defs = False
+
+[mypy-qapi.expr]
+disallow_untyped_defs = False
+disallow_incomplete_defs = False
+check_untyped_defs = False
+
+[mypy-qapi.gen]
+disallow_untyped_defs = False
+disallow_incomplete_defs = False
+check_untyped_defs = False
+
+[mypy-qapi.introspect]
+disallow_untyped_defs = False
+disallow_incomplete_defs = False
+check_untyped_defs = False
+
+[mypy-qapi.parser]
+disallow_untyped_defs = False
+disallow_incomplete_defs = False
+check_untyped_defs = False
+
+[mypy-qapi.schema]
+disallow_untyped_defs = False
+disallow_incomplete_defs = False
+check_untyped_defs = False
+
+[mypy-qapi.source]
+disallow_untyped_defs = False
+disallow_incomplete_defs = False
+check_untyped_defs = False
+
+[mypy-qapi.types]
+disallow_untyped_defs = False
+disallow_incomplete_defs = False
+check_untyped_defs = False
+
+[mypy-qapi.visit]
+disallow_untyped_defs = False
+disallow_incomplete_defs = False
+check_untyped_defs = False
diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index 74c6b96d391..483b4b68dff 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -17,6 +17,7 @@
from collections import OrderedDict
import os
import re
+from typing import Optional
from .common import POINTER_SUFFIX, c_name
from .error import QAPIError, QAPISemError
@@ -25,7 +26,7 @@
class QAPISchemaEntity:
- meta = None
+ meta: Optional[str] = None
def __init__(self, name, info, doc, ifcond=None, features=None):
assert name is None or isinstance(name, str)
--
2.26.2
- [PATCH v4 16/46] qapi/common.py: delint with pylint, (continued)
- [PATCH v4 16/46] qapi/common.py: delint with pylint, John Snow, 2020/09/30
- [PATCH v4 17/46] qapi/common.py: Replace one-letter 'c' variable, John Snow, 2020/09/30
- [PATCH v4 19/46] qapi/common.py: add type hint annotations, John Snow, 2020/09/30
- [PATCH v4 18/46] qapi/common.py: check with pylint, John Snow, 2020/09/30
- [PATCH v4 20/46] qapi/common.py: Convert comments into docstrings, and elaborate, John Snow, 2020/09/30
- [PATCH v4 25/46] qapi/commands.py: Don't re-bind to variable of different type, John Snow, 2020/09/30
- [PATCH v4 28/46] qapi/source.py: add type hint annotations, John Snow, 2020/09/30
- [PATCH v4 31/46] qapi/gen.py: add type hint annotations, John Snow, 2020/09/30
- [PATCH v4 21/46] qapi/common.py: move build_params into gen.py, John Snow, 2020/09/30
- [PATCH v4 23/46] qapi/events.py: add type hint annotations, John Snow, 2020/09/30
- [PATCH v4 22/46] qapi: establish mypy type-checking baseline,
John Snow <=
- [PATCH v4 24/46] qapi/events.py: Move comments into docstrings, John Snow, 2020/09/30
- [PATCH v4 26/46] qapi/commands.py: add type hint annotations, John Snow, 2020/09/30
- [PATCH v4 27/46] qapi/commands.py: enable checking with mypy, John Snow, 2020/09/30
- [PATCH v4 29/46] qapi/source.py: delint with pylint, John Snow, 2020/09/30
- [PATCH v4 30/46] qapi/gen.py: Fix edge-case of _is_user_module, John Snow, 2020/09/30
- [PATCH v4 34/46] qapi/gen.py: update write() to be more idiomatic, John Snow, 2020/09/30
- [PATCH v4 32/46] qapi/gen.py: Enable checking with mypy, John Snow, 2020/09/30
- [PATCH v4 33/46] qapi/gen.py: Remove unused parameter, John Snow, 2020/09/30
- [PATCH v4 35/46] qapi/gen.py: delint with pylint, John Snow, 2020/09/30