ci: add mypy type checking and fix/exclude minor issues (#255)
* add mypy type checking and fix/exclude minor issues Signed-off-by: gruebel <anton.gruebel@gmail.com> * enable explicit_package_bases for mypy Signed-off-by: gruebel <anton.gruebel@gmail.com> --------- Signed-off-by: gruebel <anton.gruebel@gmail.com>
This commit is contained in:
parent
a853b85514
commit
b3c67b6ab3
|
|
@ -14,3 +14,9 @@ repos:
|
||||||
- id: check-yaml
|
- id: check-yaml
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- id: check-merge-conflict
|
- id: check-merge-conflict
|
||||||
|
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
|
rev: v1.8.0
|
||||||
|
hooks:
|
||||||
|
- id: mypy
|
||||||
|
files: openfeature
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
try:
|
import sys
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 11):
|
||||||
from enum import StrEnum
|
from enum import StrEnum
|
||||||
except ImportError:
|
else:
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
class StrEnum(str, Enum):
|
class StrEnum(str, Enum):
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
import typing
|
||||||
|
|
||||||
|
|
||||||
class MappingProxyType(dict):
|
class MappingProxyType(dict):
|
||||||
"""
|
"""
|
||||||
MappingProxyType is an immutable dictionary type, written to
|
MappingProxyType is an immutable dictionary type, written to
|
||||||
|
|
@ -14,16 +17,16 @@ class MappingProxyType(dict):
|
||||||
`from types import MappingProxyType`
|
`from types import MappingProxyType`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __hash__(self):
|
def __hash__(self) -> int: # type:ignore[override]
|
||||||
return id(self)
|
return id(self)
|
||||||
|
|
||||||
def _immutable(self, *args, **kws):
|
def _immutable(self, *args: typing.Any, **kws: typing.Any) -> typing.NoReturn:
|
||||||
raise TypeError("immutable instance of dictionary")
|
raise TypeError("immutable instance of dictionary")
|
||||||
|
|
||||||
__setitem__ = _immutable
|
__setitem__ = _immutable
|
||||||
__delitem__ = _immutable
|
__delitem__ = _immutable
|
||||||
clear = _immutable
|
clear = _immutable
|
||||||
update = _immutable
|
update = _immutable # type:ignore[assignment]
|
||||||
setdefault = _immutable
|
setdefault = _immutable # type:ignore[assignment]
|
||||||
pop = _immutable
|
pop = _immutable # type:ignore[assignment]
|
||||||
popitem = _immutable
|
popitem = _immutable
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,11 @@ dev = ["pip-tools", "pytest", "pre-commit"]
|
||||||
[project.urls]
|
[project.urls]
|
||||||
Homepage = "https://github.com/open-feature/python-sdk"
|
Homepage = "https://github.com/open-feature/python-sdk"
|
||||||
|
|
||||||
|
[tool.mypy]
|
||||||
|
files = "openfeature"
|
||||||
|
namespace_packages = true
|
||||||
|
explicit_package_bases = true
|
||||||
|
|
||||||
[tool.ruff]
|
[tool.ruff]
|
||||||
exclude = [
|
exclude = [
|
||||||
".git",
|
".git",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue