Merge "Run mypy from tox"
This commit is contained in:
@@ -12,29 +12,15 @@ repos:
|
||||
- id: debug-statements
|
||||
- id: check-yaml
|
||||
files: .*\.(yaml|yml)$
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.14.8
|
||||
hooks:
|
||||
- id: ruff-check
|
||||
args: ['--fix', '--unsafe-fixes']
|
||||
- id: ruff-format
|
||||
- repo: https://opendev.org/openstack/hacking
|
||||
rev: 8.0.0
|
||||
hooks:
|
||||
- id: hacking
|
||||
additional_dependencies: []
|
||||
exclude: '^(doc|releasenotes|tools)/.*$'
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.14.5
|
||||
hooks:
|
||||
- id: ruff-check
|
||||
args: ['--fix', '--unsafe-fixes']
|
||||
- id: ruff-format
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v1.18.2
|
||||
hooks:
|
||||
- id: mypy
|
||||
additional_dependencies: [
|
||||
'types-requests',
|
||||
'types-WebOb>=1.8.0.20250822',
|
||||
]
|
||||
# keep this in-sync with '[tool.mypy] exclude' in 'pyproject.toml'
|
||||
exclude: |
|
||||
(?x)(
|
||||
doc/.*
|
||||
| releasenotes/.*
|
||||
)
|
||||
|
||||
@@ -38,7 +38,7 @@ import webob.response
|
||||
try:
|
||||
import greenlet
|
||||
except ImportError:
|
||||
greenlet = None
|
||||
greenlet = None # type: ignore
|
||||
|
||||
from oslo_middleware import base
|
||||
from oslo_middleware.exceptions import ConfigInvalid
|
||||
@@ -418,6 +418,10 @@ Reason
|
||||
# `disable_by_file` backends are not enabled at same time.
|
||||
self._verify_configured_plugins()
|
||||
|
||||
if ty.TYPE_CHECKING:
|
||||
self._backends: stevedore.NamedExtensionManager[
|
||||
pluginbase.HealthcheckBaseExtension
|
||||
]
|
||||
self._backends = stevedore.NamedExtensionManager(
|
||||
self.NAMESPACE,
|
||||
self._conf_get('backends'),
|
||||
@@ -648,7 +652,9 @@ Reason
|
||||
return None
|
||||
|
||||
results = [
|
||||
ext.obj.healthcheck(req.server_port) for ext in self._backends
|
||||
ext.obj.healthcheck(req.server_port)
|
||||
for ext in self._backends
|
||||
if ext.obj
|
||||
]
|
||||
healthy = self._are_results_healthy(results)
|
||||
if req.method == "HEAD":
|
||||
|
||||
@@ -10,12 +10,14 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslotest import base
|
||||
from oslotest import base as test_base
|
||||
import stevedore
|
||||
from testtools import matchers
|
||||
|
||||
from oslo_middleware import base
|
||||
|
||||
class TestPasteDeploymentEntryPoints(base.BaseTestCase):
|
||||
|
||||
class TestPasteDeploymentEntryPoints(test_base.BaseTestCase):
|
||||
def test_entry_points(self):
|
||||
factory_classes = {
|
||||
'catch_errors': 'CatchErrors',
|
||||
@@ -27,6 +29,7 @@ class TestPasteDeploymentEntryPoints(base.BaseTestCase):
|
||||
'sizelimit': 'RequestBodySizeLimiter',
|
||||
}
|
||||
|
||||
em: stevedore.ExtensionManager[base.ConfigurableMiddleware]
|
||||
em = stevedore.ExtensionManager('paste.filter_factory')
|
||||
|
||||
# Ensure all the factories are defined by their names
|
||||
@@ -40,6 +43,7 @@ class TestPasteDeploymentEntryPoints(base.BaseTestCase):
|
||||
'enable_by_files': 'EnableByFilesHealthcheck',
|
||||
}
|
||||
|
||||
em: stevedore.ExtensionManager[base.ConfigurableMiddleware]
|
||||
em = stevedore.ExtensionManager('oslo.middleware.healthcheck')
|
||||
|
||||
# Ensure all the healthcheck plugins are defined by their names
|
||||
|
||||
@@ -78,13 +78,8 @@ python_version = "3.10"
|
||||
show_column_numbers = true
|
||||
show_error_context = true
|
||||
strict = true
|
||||
# keep this in-sync with 'mypy.exclude' in '.pre-commit-config.yaml'
|
||||
exclude = '''
|
||||
(?x)(
|
||||
doc
|
||||
| releasenotes
|
||||
)
|
||||
'''
|
||||
ignore_missing_imports = true
|
||||
exclude = '(?x)(doc | releasenotes)'
|
||||
|
||||
[[tool.mypy.overrides]]
|
||||
module = ["oslo_middleware.tests.*"]
|
||||
|
||||
@@ -10,6 +10,6 @@ oslo.i18n>=3.15.3 # Apache-2.0
|
||||
oslo.utils>=3.33.0 # Apache-2.0
|
||||
pbr>=2.0.0 # Apache-2.0
|
||||
statsd>=3.2.1 # MIT
|
||||
stevedore>=1.20.0 # Apache-2.0
|
||||
stevedore>=5.6.0 # Apache-2.0
|
||||
typing-extensions>=4.11.0 # PSF-2.0
|
||||
WebOb>=1.8.0 # MIT
|
||||
|
||||
17
tox.ini
17
tox.ini
@@ -9,11 +9,26 @@ deps =
|
||||
commands = stestr run --slowest {posargs}
|
||||
|
||||
[testenv:pep8]
|
||||
skip_install = true
|
||||
description =
|
||||
Run style checks.
|
||||
deps =
|
||||
pre-commit
|
||||
{[testenv:mypy]deps}
|
||||
commands =
|
||||
pre-commit run -a
|
||||
{[testenv:mypy]commands}
|
||||
|
||||
[testenv:mypy]
|
||||
description =
|
||||
Run type checks.
|
||||
deps =
|
||||
{[testenv]deps}
|
||||
mypy
|
||||
types-greenlet
|
||||
types-requests
|
||||
types-WebOb>=1.8.0.20250822
|
||||
commands =
|
||||
mypy --cache-dir="{envdir}/mypy_cache" {posargs:oslo_middleware}
|
||||
|
||||
[testenv:venv]
|
||||
commands = {posargs}
|
||||
|
||||
Reference in New Issue
Block a user