[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 23/47] qapi: establish mypy type-checking baseline
From: |
John Snow |
Subject: |
[PATCH v3 23/47] qapi: establish mypy type-checking baseline |
Date: |
Thu, 24 Sep 2020 20:28:36 -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>
---
scripts/qapi/doc.py | 3 +-
scripts/qapi/mypy.ini | 65 ++++++++++++++++++++++++++++++++++++++++++
scripts/qapi/schema.py | 3 +-
3 files changed, 69 insertions(+), 2 deletions(-)
create mode 100644 scripts/qapi/mypy.ini
diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py
index 1acb773e0a..42ef19ddf6 100644
--- a/scripts/qapi/doc.py
+++ b/scripts/qapi/doc.py
@@ -6,7 +6,8 @@
import re
-from .gen import QAPIGenDoc, QAPISchemaVisitor
+from .gen import QAPIGenDoc
+from .schema import QAPISchemaVisitor
_MSG = '''
@deftypefn {type} {{}} {name}
diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini
new file mode 100644
index 0000000000..a0f2365a53
--- /dev/null
+++ b/scripts/qapi/mypy.ini
@@ -0,0 +1,65 @@
+[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.doc]
+disallow_subclassing_any = False
+disallow_untyped_defs = False
+disallow_incomplete_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 74c6b96d39..483b4b68df 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 v3 05/47] qapi/doc.py: Change code templates from function to string, (continued)
- [PATCH v3 05/47] qapi/doc.py: Change code templates from function to string, John Snow, 2020/09/24
- [PATCH v3 15/47] qapi/common.py: Remove python compatibility workaround, John Snow, 2020/09/24
- [PATCH v3 20/47] qapi/common.py: add type hint annotations, John Snow, 2020/09/24
- [PATCH v3 17/47] qapi/common.py: delint with pylint, John Snow, 2020/09/24
- [PATCH v3 14/47] qapi: add pylintrc, John Snow, 2020/09/24
- [PATCH v3 24/47] qapi/events.py: add type hint annotations, John Snow, 2020/09/24
- [PATCH v3 19/47] qapi/common.py: check with pylint, John Snow, 2020/09/24
- [PATCH v3 23/47] qapi: establish mypy type-checking baseline,
John Snow <=
- [PATCH v3 33/47] qapi/gen.py: Enable checking with mypy, John Snow, 2020/09/24
- [PATCH v3 25/47] qapi/events.py: Move comments into docstrings, John Snow, 2020/09/24
- [PATCH v3 16/47] qapi/common.py: Add indent manager, John Snow, 2020/09/24
- [PATCH v3 22/47] qapi/common.py: move build_params into gen.py, John Snow, 2020/09/24
- [PATCH v3 35/47] qapi/gen.py: update write() to be more idiomatic, John Snow, 2020/09/24
- [PATCH v3 27/47] qapi/commands.py: add type hint annotations, John Snow, 2020/09/24
- [PATCH v3 36/47] qapi/gen.py: delint with pylint, John Snow, 2020/09/24
- [PATCH v3 21/47] qapi/common.py: Convert comments into docstrings, and elaborate, John Snow, 2020/09/24
- [PATCH v3 41/47] qapi/introspect.py: replace 'extra' dict with 'comment' argument, John Snow, 2020/09/24