Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add mypy type checking and fix/exclude minor issues #255

Merged
merged 2 commits into from
Jan 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ repos:
- id: check-yaml
- id: trailing-whitespace
- id: check-merge-conflict

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
files: openfeature
Empty file added openfeature/__init__.py
Empty file.
6 changes: 4 additions & 2 deletions openfeature/_backports/strenum.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
try:
import sys

if sys.version_info >= (3, 11):
from enum import StrEnum
except ImportError:
else:
from enum import Enum

class StrEnum(str, Enum):
Expand Down
13 changes: 8 additions & 5 deletions openfeature/immutable_dict/mapping_proxy_type.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import typing


class MappingProxyType(dict):
"""
MappingProxyType is an immutable dictionary type, written to
Expand All @@ -14,16 +17,16 @@ class MappingProxyType(dict):
`from types import MappingProxyType`
"""

def __hash__(self):
def __hash__(self) -> int: # type:ignore[override]
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")

__setitem__ = _immutable
__delitem__ = _immutable
clear = _immutable
update = _immutable
setdefault = _immutable
pop = _immutable
update = _immutable # type:ignore[assignment]
setdefault = _immutable # type:ignore[assignment]
pop = _immutable # type:ignore[assignment]
popitem = _immutable
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ dev = ["pip-tools", "pytest", "pre-commit"]
[project.urls]
Homepage = "https://github.com/open-feature/python-sdk"

[tool.mypy]
files = "openfeature"

[tool.ruff]
exclude = [
".git",
Expand Down
Loading