Python Pull Request

Add QAPI and QAPI doc files to python static analysis testing regime,
 this time for real, probably
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE+ber27ys35W+dsvQfe+BBqr8OQ4FAmhB388ACgkQfe+BBqr8
 OQ6lMA//WJtSr57ADW5k5zcRMxV7k//erYFkjgXbTh7b9DDblMwNVhYr5lqJbEvS
 V5OChW32++QIO5Y4cBhzbzxFTJXbAYzyg3UATCkH2kRbd139bqdAtsnsaFmoHmLP
 c8KAggT1+hIb7JIVkFiFccMsdCeFwXwQoS5Nk7w95H9cxxYUj/O9qbRuCN+elg/e
 mX4zaq6F2umTx0EdD35DlBPrPPyRsdlVWKUqh8f5KaAGPOelGyvbgwrXU2MT7ewG
 JXcRoYzn/9J2KSboiFY0MjIKqDuhoMdCnbSNpRNGgClJRa+VZEBPFClMe1YSXw0m
 J3kQMYeqm5S1GUG+ZrBTICY6Ch8jNq2kb3ua707JJWdYmd9gq0poF/P7gaRVbyAL
 5UdYVVgtH/3xve2LGe0guj3v5kTK7Vo6dApwj8pRHrBWWOgAG0UgGseOJgndfCIx
 PQRsF2T4YoVdjiGB46EIgBmoFI+VJGwFRlvb6WZ0YmPedi7MuUvWmo0lbgDkaTO+
 MMqsWxShTY+xwnSFgtl1iHOAdfT6jiHcn1n+hZrGpvF492XRjW02zKiDSZECqSz5
 lg51+OaDc2HwS65sYyFb4GD7yF/PcdOj7MG/Ij9dx0GoM9/HmcVAHyRt45QNgxzc
 N7Xx6GFGs7puDoE/pSoauFtGC8XeR6Cx0HfBcXYGaJcJEq6N4yw=
 =IVAr
 -----END PGP SIGNATURE-----

Merge tag 'python-pull-request' of https://gitlab.com/jsnow/qemu into staging

Python Pull Request

Add QAPI and QAPI doc files to python static analysis testing regime,
this time for real, probably

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCAAdFiEE+ber27ys35W+dsvQfe+BBqr8OQ4FAmhB388ACgkQfe+BBqr8
# OQ6lMA//WJtSr57ADW5k5zcRMxV7k//erYFkjgXbTh7b9DDblMwNVhYr5lqJbEvS
# V5OChW32++QIO5Y4cBhzbzxFTJXbAYzyg3UATCkH2kRbd139bqdAtsnsaFmoHmLP
# c8KAggT1+hIb7JIVkFiFccMsdCeFwXwQoS5Nk7w95H9cxxYUj/O9qbRuCN+elg/e
# mX4zaq6F2umTx0EdD35DlBPrPPyRsdlVWKUqh8f5KaAGPOelGyvbgwrXU2MT7ewG
# JXcRoYzn/9J2KSboiFY0MjIKqDuhoMdCnbSNpRNGgClJRa+VZEBPFClMe1YSXw0m
# J3kQMYeqm5S1GUG+ZrBTICY6Ch8jNq2kb3ua707JJWdYmd9gq0poF/P7gaRVbyAL
# 5UdYVVgtH/3xve2LGe0guj3v5kTK7Vo6dApwj8pRHrBWWOgAG0UgGseOJgndfCIx
# PQRsF2T4YoVdjiGB46EIgBmoFI+VJGwFRlvb6WZ0YmPedi7MuUvWmo0lbgDkaTO+
# MMqsWxShTY+xwnSFgtl1iHOAdfT6jiHcn1n+hZrGpvF492XRjW02zKiDSZECqSz5
# lg51+OaDc2HwS65sYyFb4GD7yF/PcdOj7MG/Ij9dx0GoM9/HmcVAHyRt45QNgxzc
# N7Xx6GFGs7puDoE/pSoauFtGC8XeR6Cx0HfBcXYGaJcJEq6N4yw=
# =IVAr
# -----END PGP SIGNATURE-----
# gpg: Signature made Thu 05 Jun 2025 14:19:59 EDT
# gpg:                using RSA key F9B7ABDBBCACDF95BE76CBD07DEF8106AAFC390E
# gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>" [full]
# Primary key fingerprint: FAEB 9711 A12C F475 812F  18F2 88A9 064D 1835 61EB
#      Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76  CBD0 7DEF 8106 AAFC 390E

* tag 'python-pull-request' of https://gitlab.com/jsnow/qemu:
  qapi: delete un-needed python static analysis configs
  python: Drop redundant warn_unused_configs = True
  python: add qapi static analysis tests
  python: update missing dependencies from minreqs
  docs/qapidoc: linting fixes
  qapi: Add some pylint ignores

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Stefan Hajnoczi 2025-06-06 09:42:49 -04:00
commit fc8da54ec4
13 changed files with 78 additions and 28 deletions

View file

@ -20,16 +20,6 @@ from typing import (
from docutils import nodes
from docutils.parsers.rst import directives
from compat import (
CompatField,
CompatGroupedField,
CompatTypedField,
KeywordNode,
ParserFix,
Signature,
SpaceNode,
)
from sphinx import addnodes
from sphinx.directives import ObjectDescription
from sphinx.domains import (
@ -44,6 +34,16 @@ from sphinx.util import logging
from sphinx.util.docutils import SphinxDirective
from sphinx.util.nodes import make_id, make_refnode
from compat import (
CompatField,
CompatGroupedField,
CompatTypedField,
KeywordNode,
ParserFix,
Signature,
SpaceNode,
)
if TYPE_CHECKING:
from typing import (
@ -56,7 +56,6 @@ if TYPE_CHECKING:
)
from docutils.nodes import Element, Node
from sphinx.addnodes import desc_signature, pending_xref
from sphinx.application import Sphinx
from sphinx.builders import Builder
@ -168,6 +167,8 @@ class QAPIDescription(ParserFix):
"""
def handle_signature(self, sig: str, signode: desc_signature) -> Signature:
# pylint: disable=unused-argument
# Do nothing. The return value here is the "name" of the entity
# being documented; for QAPI, this is the same as the
# "signature", which is just a name.
@ -210,6 +211,8 @@ class QAPIDescription(ParserFix):
def add_target_and_index(
self, name: Signature, sig: str, signode: desc_signature
) -> None:
# pylint: disable=unused-argument
# name is the return value of handle_signature.
# sig is the original, raw text argument to handle_signature.
# For QAPI, these are identical, currently.

View file

@ -27,6 +27,7 @@ https://www.sphinx-doc.org/en/master/development/index.html
from __future__ import annotations
__version__ = "2.0"
from contextlib import contextmanager
@ -56,8 +57,6 @@ from qapi.schema import (
QAPISchemaVisitor,
)
from qapi.source import QAPISourceInfo
from qapidoc_legacy import QAPISchemaGenRSTVisitor # type: ignore
from sphinx import addnodes
from sphinx.directives.code import CodeBlock
from sphinx.errors import ExtensionError
@ -65,6 +64,8 @@ from sphinx.util import logging
from sphinx.util.docutils import SphinxDirective, switch_source_input
from sphinx.util.nodes import nested_parse_with_titles
from qapidoc_legacy import QAPISchemaGenRSTVisitor # type: ignore
if TYPE_CHECKING:
from typing import (

View file

@ -46,6 +46,7 @@ devel =
urwid >= 2.1.2
urwid-readline >= 0.13
Pygments >= 2.9.0
sphinx >= 3.4.3
# Provides qom-fuse functionality
fuse =
@ -78,7 +79,6 @@ exclude = __pycache__,
[mypy]
strict = True
python_version = 3.9
warn_unused_configs = True
namespace_packages = True
warn_unused_ignores = False

View file

@ -11,6 +11,15 @@
# When adding new dependencies, pin the very oldest non-yanked version
# on PyPI that allows the test suite to pass.
# For some reason, the presence of packaging==14.0 below requires us to
# also pin setuptools to version 70 or below. Otherwise, the
# installation of the QEMU package itself fails, failing to find
# setuptools.
setuptools<=70
# Dependencies for qapidoc/qapi_domain et al
sphinx==3.4.3
# Dependencies for the TUI addon (Required for successful linting)
urwid==2.1.2
urwid-readline==0.13
@ -38,10 +47,32 @@ pyflakes==2.5.0
# Transitive mypy dependencies
mypy-extensions==1.0.0
tomli==1.1.0
typing-extensions==4.7.1
# Transitive pylint dependencies
astroid==2.15.4
dill==0.2
lazy-object-proxy==1.4.0
platformdirs==2.2.0
toml==0.10.0
tomlkit==0.10.1
wrapt==1.14.0
# Transitive sphinx dependencies
Jinja2==2.7
MarkupSafe==1.1.0
alabaster==0.7.1
babel==1.3
docutils==0.12
imagesize==0.5.0
packaging==14.0
pytz==2011b0
requests==2.5.0
snowballstemmer==1.1
sphinxcontrib-applehelp==1.0.0
sphinxcontrib-devhelp==1.0.0
sphinxcontrib-htmlhelp==1.0.0
sphinxcontrib-jsmath==1.0.0
sphinxcontrib-qthelp==1.0.0
sphinxcontrib-serializinghtml==1.0.0

6
python/tests/qapi-flake8.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/sh -e
# SPDX-License-Identifier: GPL-2.0-or-later
python3 -m flake8 ../scripts/qapi/ \
../docs/sphinx/qapidoc.py \
../docs/sphinx/qapi_domain.py

8
python/tests/qapi-isort.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/sh -e
# SPDX-License-Identifier: GPL-2.0-or-later
python3 -m isort --sp . -c ../scripts/qapi/
# Force isort to recognize "compat" as a local module and not third-party
python3 -m isort --sp . -c -p compat -p qapidoc_legacy \
../docs/sphinx/qapi_domain.py \
../docs/sphinx/qapidoc.py

4
python/tests/qapi-mypy.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/sh -e
# SPDX-License-Identifier: GPL-2.0-or-later
python3 -m mypy ../scripts/qapi

8
python/tests/qapi-pylint.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/sh -e
# SPDX-License-Identifier: GPL-2.0-or-later
SETUPTOOLS_USE_DISTUTILS=stdlib python3 -m pylint \
--rcfile=../scripts/qapi/pylintrc \
../scripts/qapi/ \
../docs/sphinx/qapidoc.py \
../docs/sphinx/qapi_domain.py

View file

@ -1,3 +0,0 @@
[flake8]
# Prefer pylint's bare-except checks to flake8's
extend-ignore = E722

View file

@ -1,7 +0,0 @@
[settings]
force_grid_wrap=4
force_sort_within_sections=True
include_trailing_comma=True
line_length=72
lines_after_imports=2
multi_line_output=3

View file

@ -13,6 +13,7 @@ from .visit import gen_visit
class QAPIBackend(ABC):
# pylint: disable=too-few-public-methods
@abstractmethod
def generate(self,
@ -36,6 +37,7 @@ class QAPIBackend(ABC):
class QAPICBackend(QAPIBackend):
# pylint: disable=too-few-public-methods
def generate(self,
schema: QAPISchema,

View file

@ -1,4 +0,0 @@
[mypy]
strict = True
disallow_untyped_calls = False
python_version = 3.9

View file

@ -19,6 +19,7 @@ disable=consider-using-f-string,
too-many-instance-attributes,
too-many-positional-arguments,
too-many-statements,
unknown-option-value,
useless-option-value,
[REPORTS]