Add a "mypy" tox environment which runs mypy type checking against Cinder code. Taken from Stephen Finucane's Nova work at https://review.opendev.org/#/c/676208/ Added "show_error_codes" and "pretty" options. Generates an html report in ./mypy-report/ This adds stubs for oslo.i18n, so that _() calls are annotated as intended. It may be possible to do this with less .pyi files carried along here. Change-Id: I2589d22c1f16f2e177d34730a520591743c0c1e3changes/20/733620/13
parent
2ce35aa94b
commit
6e53c264b6
@ -0,0 +1,8 @@
|
||||
# Stubs for oslo_i18n (Python 3)
|
||||
#
|
||||
# NOTE: This dynamically typed stub was automatically generated by stubgen.
|
||||
|
||||
from ._factory import *
|
||||
from ._gettextutils import *
|
||||
from ._lazy import *
|
||||
from ._translate import *
|
@ -0,0 +1,24 @@
|
||||
# Stubs for oslo_i18n._factory (Python 3)
|
||||
#
|
||||
# NOTE: This dynamically typed stub was automatically generated by stubgen.
|
||||
|
||||
from typing import Any, Optional
|
||||
|
||||
class TranslatorFactory:
|
||||
domain: Any = ...
|
||||
localedir: Any = ...
|
||||
def __init__(self, domain: Any, localedir: Optional[Any] = ...) -> None: ...
|
||||
@property
|
||||
def primary(self) -> ty.Callable[str]: ...
|
||||
@property
|
||||
def contextual_form(self): ...
|
||||
@property
|
||||
def plural_form(self): ...
|
||||
@property
|
||||
def log_info(self): ...
|
||||
@property
|
||||
def log_warning(self): ...
|
||||
@property
|
||||
def log_error(self): ...
|
||||
@property
|
||||
def log_critical(self): ...
|
@ -0,0 +1,8 @@
|
||||
# Stubs for oslo_i18n._gettextutils (Python 3)
|
||||
#
|
||||
# NOTE: This dynamically typed stub was automatically generated by stubgen.
|
||||
|
||||
from typing import Any
|
||||
|
||||
def install(domain: Any) -> None: ...
|
||||
def get_available_languages(domain: Any): ...
|
@ -0,0 +1,4 @@
|
||||
# Stubs for oslo_i18n._i18n (Python 3)
|
||||
#
|
||||
# NOTE: This dynamically typed stub was automatically generated by stubgen.
|
||||
|
@ -0,0 +1,5 @@
|
||||
# Stubs for oslo_i18n._lazy (Python 3)
|
||||
#
|
||||
# NOTE: This dynamically typed stub was automatically generated by stubgen.
|
||||
|
||||
def enable_lazy(enable: bool = ...) -> None: ...
|
@ -0,0 +1,7 @@
|
||||
# Stubs for oslo_i18n._locale (Python 3)
|
||||
#
|
||||
# NOTE: This dynamically typed stub was automatically generated by stubgen.
|
||||
|
||||
from typing import Any
|
||||
|
||||
def get_locale_dir_variable_name(domain: Any): ...
|
@ -0,0 +1,16 @@
|
||||
# Stubs for oslo_i18n._message (Python 3)
|
||||
#
|
||||
# NOTE: This dynamically typed stub was automatically generated by stubgen.
|
||||
|
||||
import six
|
||||
from typing import Any, Optional
|
||||
|
||||
CONTEXT_SEPARATOR: str
|
||||
LOG: Any
|
||||
|
||||
class Message(six.text_type):
|
||||
def __new__(cls, msgid: Any, msgtext: Optional[Any] = ..., params: Optional[Any] = ..., domain: str = ..., has_contextual_form: bool = ..., has_plural_form: bool = ..., *args: Any): ...
|
||||
def translation(self, desired_locale: Optional[Any] = ...): ...
|
||||
def __mod__(self, other: Any): ...
|
||||
def __add__(self, other: Any) -> None: ...
|
||||
def __radd__(self, other: Any): ...
|
@ -0,0 +1,7 @@
|
||||
# Stubs for oslo_i18n._translate (Python 3)
|
||||
#
|
||||
# NOTE: This dynamically typed stub was automatically generated by stubgen.
|
||||
|
||||
from typing import Any, Optional
|
||||
|
||||
def translate(obj: Any, desired_locale: Optional[Any] = ...): ...
|
@ -0,0 +1,29 @@
|
||||
# Stubs for oslo_i18n.fixture (Python 3)
|
||||
#
|
||||
# NOTE: This dynamically typed stub was automatically generated by stubgen.
|
||||
|
||||
import fixtures
|
||||
import gettext
|
||||
from typing import Any, Optional
|
||||
|
||||
class Translation(fixtures.Fixture):
|
||||
domain: Any = ...
|
||||
def __init__(self, domain: str = ...) -> None: ...
|
||||
def lazy(self, msg: Any): ...
|
||||
def immediate(self, msg: Any): ...
|
||||
|
||||
class ToggleLazy(fixtures.Fixture):
|
||||
def __init__(self, enabled: Any) -> None: ...
|
||||
def setUp(self) -> None: ...
|
||||
|
||||
class _PrefixTranslator(gettext.NullTranslations):
|
||||
prefix: Any = ...
|
||||
def __init__(self, fp: Optional[Any] = ..., prefix: str = ...) -> None: ...
|
||||
def gettext(self, message: Any): ...
|
||||
def ugettext(self, message: Any): ...
|
||||
|
||||
class PrefixLazyTranslation(fixtures.Fixture):
|
||||
languages: Any = ...
|
||||
locale: Any = ...
|
||||
def __init__(self, languages: Optional[Any] = ..., locale: Optional[Any] = ...) -> None: ...
|
||||
def setUp(self): ...
|
@ -0,0 +1,12 @@
|
||||
# Stubs for oslo_i18n.log (Python 3)
|
||||
#
|
||||
# NOTE: This dynamically typed stub was automatically generated by stubgen.
|
||||
|
||||
from logging import handlers
|
||||
from typing import Any, Optional
|
||||
|
||||
class TranslationHandler(handlers.MemoryHandler):
|
||||
locale: Any = ...
|
||||
def __init__(self, locale: Optional[Any] = ..., target: Optional[Any] = ...) -> None: ...
|
||||
def setFormatter(self, fmt: Any) -> None: ...
|
||||
def emit(self, record: Any) -> None: ...
|
@ -0,0 +1,3 @@
|
||||
cinder/i18n.py
|
||||
cinder/manager.py
|
||||
cinder/volume/__init__.py
|
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# A wrapper around mypy that allows us to specify what files to run 'mypy' type
|
||||
# checks on. Intended to be invoked via tox:
|
||||
#
|
||||
# tox -e mypy
|
||||
#
|
||||
# Eventually this should go away once we have either converted everything or
|
||||
# converted enough and ignored [1] the rest.
|
||||
#
|
||||
# [1] http://mypy.readthedocs.io/en/latest/config_file.html#per-module-flags
|
||||
|
||||
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
export MYPYPATH=$ROOT_DIR/../cinder/tests/stubs/
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
# if no arguments provided, use the standard converted lists
|
||||
lines=$(grep -v '#' $ROOT_DIR/../mypy-files.txt)
|
||||
python -m mypy ${lines[@]}
|
||||
else
|
||||
# else test what the user asked us to
|
||||
python -m mypy $@
|
||||
fi
|
Loading…
Reference in new issue