Skip to content

Commit 80399aa

Browse files
committed
Enable mypy
1 parent fda9fbd commit 80399aa

File tree

7 files changed

+92
-8
lines changed

7 files changed

+92
-8
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ repos:
1515
- id: pyupgrade
1616
args: ["--py36-plus"]
1717

18+
- repo: https://github.com/pre-commit/mirrors-mypy
19+
rev: v0.910
20+
hooks:
21+
- id: mypy
22+
args: []
23+
additional_dependencies: [types-requests==2.25.6]
24+
1825
- repo: local
1926
hooks:
2027
- id: flynt

openapi_core/templating/datatypes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from dataclasses import dataclass
2+
from dataclasses import field
23
from typing import Dict
3-
from typing import Optional
44

55

66
@dataclass
77
class TemplateResult:
8-
pattern: Optional[str] = None
9-
variables: Optional[Dict] = None
8+
pattern: str
9+
variables: Dict = field(default_factory=dict)
1010

1111
@property
1212
def resolved(self):

openapi_core/templating/paths/finders.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def _get_paths_iter(self, full_url_pattern):
5050
# simple path.
5151
# Return right away since it is always the most concrete
5252
if full_url_pattern.endswith(path_pattern):
53-
path_result = TemplateResult(path_pattern, {})
53+
path_result = TemplateResult(path_pattern)
5454
yield (path, path_result)
5555
# template path
5656
else:
@@ -93,7 +93,7 @@ def _get_servers_iter(self, full_url_pattern, ooperations_iter):
9393
server_url = server_url[:-1]
9494
# simple path
9595
if server_url_pattern == server_url:
96-
server_result = TemplateResult(server["url"], {})
96+
server_result = TemplateResult(server["url"])
9797
yield (
9898
path,
9999
operation,

openapi_core/testing/factories.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
from typing import Dict
2+
3+
14
class FactoryClassMock:
25

3-
_instances = {}
6+
_instances: Dict[object, object] = {}
47

58
def __new__(cls, obj):
69
if obj not in cls._instances:

openapi_core/unmarshalling/schemas/unmarshallers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import logging
22
from functools import partial
3+
from typing import Dict
4+
from typing import Optional
35

46
from isodate.isodatetime import parse_datetime
57
from openapi_schema_validator._format import oas30_format_checker
@@ -32,7 +34,7 @@
3234

3335
class BaseSchemaUnmarshaller:
3436

35-
FORMATTERS = {
37+
FORMATTERS: Dict[Optional[str], Formatter] = {
3638
None: Formatter(),
3739
}
3840

poetry.lock

Lines changed: 56 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ source =["openapi_core"]
99
[tool.coverage.xml]
1010
output = "reports/coverage.xml"
1111

12+
[tool.mypy]
13+
files = "openapi_core"
14+
15+
[[tool.mypy.overrides]]
16+
module = [
17+
"django.*",
18+
"falcon.*",
19+
"isodate.*",
20+
"more_itertools.*",
21+
"openapi_spec_validator.*",
22+
"openapi_schema_validator.*",
23+
"werkzeug.*",
24+
]
25+
ignore_missing_imports = true
26+
1227
[tool.poetry]
1328
name = "openapi-core"
1429
version = "0.14.2"
@@ -69,6 +84,8 @@ sphinx = "^4.0.2"
6984
sphinx-rtd-theme = "^0.5.2"
7085
strict-rfc3339 = "^0.7"
7186
webob = "*"
87+
mypy = "^0.910"
88+
types-requests = "^2.25.6"
7289

7390
[tool.pytest.ini_options]
7491
addopts = """

0 commit comments

Comments
 (0)