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