Run mypy from tox

This avoids the need to duplicate our dependency list in multiple
places and allows us to take advantage of tox's dependency management
infrastructure, to ensure we always get the latest and greatest version
of a package allowed by upper-constraints

We also fix a minor typing issues that enabling type hints for tests
highlighted and add the 'Typing :: Typed' classifier.

Change-Id: I2250e7c20460e95154a3a0954474f3c5b6b5c8bb
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane committed 2026-01-05 15:20:10 +00:00
1 parent 7e0b0ba8b2
commit 7d82840705
5 files changed
+23 -21

No files matched your search

+2 -14
View File
@@ -15,26 +15,14 @@ repos:
files: .*\.(yaml|yml)$
exclude: '^zuul.d/.*$'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.1
rev: v0.14.10
hooks:
- id: ruff-check
args: ['--fix', '--unsafe-fixes']
- id: ruff-format
- repo: https://opendev.org/openstack/hacking
rev: 7.0.0
rev: 8.0.0
hooks:
- id: hacking
exclude: '^(doc|releasenotes|tools)/.*$'
additional_dependencies: []
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.18.2
hooks:
- id: mypy
# keep this in-sync with '[mypy] exclude' in 'pyproject.toml'
exclude: |
(?x)(
doc/.*
| releasenotes/.*
)
additional_dependencies:
- types-requests
+3 -2
View File
@@ -12,13 +12,14 @@
__all__ = ['__version__', 'ServiceTypes']
from typing import TYPE_CHECKING, Optional
from typing import TYPE_CHECKING
import pbr.version
from os_service_types.service_types import ServiceTypes
if TYPE_CHECKING:
from keystoneauth1 import session as ksa_session
from requests import sessions
__version__ = pbr.version.VersionInfo('os-service-types').version_string()
@@ -26,7 +27,7 @@ _service_type_manager = None
def get_service_types(
session: Optional['sessions.Session'] = None,
session: 'sessions.Session | ksa_session.Session | None' = None,
only_remote: bool = False,
warn: bool = False,
) -> ServiceTypes:
+3 -2
View File
@@ -14,13 +14,14 @@
# limitations under the License.
import copy
from typing import TYPE_CHECKING, Optional, overload
from typing import TYPE_CHECKING, overload
import os_service_types.data
from os_service_types import exc
from os_service_types import types
if TYPE_CHECKING:
from keystoneauth1 import session as ksa_session
from requests import sessions
__all__ = ['ServiceTypes']
@@ -71,7 +72,7 @@ class ServiceTypes:
def __init__(
self,
session: Optional['sessions.Session'] = None,
session: 'sessions.Session | ksa_session.Session | None' = None,
only_remote: bool = False,
warn: bool = False,
) -> None:
+2 -1
View File
@@ -23,6 +23,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Typing :: Typed",
]
[project.urls]
@@ -39,7 +40,7 @@ python_version = "3.10"
show_column_numbers = true
show_error_context = true
strict = true
extra_checks = true
disable_error_code = ["import-untyped"]
# keep this in-sync with 'mypy.exclude' in '.pre-commit-config.yaml'
exclude = '''
(?x)(
+13 -2
View File
@@ -15,11 +15,22 @@ commands =
[testenv:pep8]
description =
Run style checks.
skip_install = true
deps =
pre-commit
{[testenv:mypy]deps}
commands =
pre-commit run --all-files --show-diff-on-failure
pre-commit run -a
{[testenv:mypy]commands}
[testenv:mypy]
description =
Run type checks.
deps =
{[testenv]deps}
mypy
types-requests
commands =
mypy --cache-dir="{envdir}/mypy_cache" {posargs:os_service_types}
[testenv:venv]
commands = {posargs}