Skip to content

Commit 7ef8b93

Browse files
committed
Add flake8 checking, break CI checks into individual steps.
1 parent e578ed7 commit 7ef8b93

File tree

8 files changed

+107
-24
lines changed

8 files changed

+107
-24
lines changed

.circleci/config.yml

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,37 @@ jobs:
2323
poetry install
2424
2525
- run:
26-
name: Run Tests
27-
command: |
28-
mkdir -p test-reports/safety test-reports/mypy test-reports/pytest
29-
poetry run black . --check
30-
poetry run isort . --check
31-
poetry run safety check --json > test-reports/safety/results.json
32-
poetry run mypy openapi_python_client --junit-xml=test-reports/mypy/results.xml
33-
poetry run pytest --junitxml=test-reports/pytest/results.xml --cov=openapi_python_client tests
34-
poetry run pytest end_to_end_tests
35-
poetry run coverage xml
26+
name: Create Test Results Dir
27+
command: mkdir -p test-reports/safety test-reports/mypy test-reports/pytest
28+
29+
- run:
30+
name: Black
31+
command: poetry run black . --check
32+
33+
- run:
34+
name: isort
35+
command: poetry run isort . --check
36+
37+
- run:
38+
name: Safety
39+
command: poetry run safety check --json > test-reports/safety/results.json
40+
41+
- run:
42+
name: mypy
43+
command: poetry run mypy openapi_python_client --junit-xml=test-reports/mypy/results.xml
44+
45+
- run:
46+
name: Unit Tests
47+
command: poetry run pytest --junitxml=test-reports/pytest/results.xml --cov=openapi_python_client tests
48+
49+
- run:
50+
name: End to End Test
51+
command: poetry run pytest end_to_end_tests
52+
53+
- run:
54+
name: Generate Coverage Report
55+
command: poetry run coverage xml
56+
3657
- store_test_results:
3758
path: test-reports
3859
- codecov/upload:

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[flake8]
2+
max-line-length = 120

openapi_python_client/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def _process_config(path: Optional[pathlib.Path]) -> None:
2626

2727
try:
2828
load_config(path=path)
29-
except:
29+
except: # noqa
3030
raise typer.BadParameter("Unable to parse config")
3131

3232

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
""" Classes representing the data in the OpenAPI schema """
22

3+
__all__ = ["OpenAPI", "import_string_from_reference"]
4+
35
from .openapi import OpenAPI, import_string_from_reference

openapi_python_client/openapi_parser/openapi.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from dataclasses import dataclass, field
44
from enum import Enum
5-
from typing import Any, Dict, Generator, Iterable, List, Optional, Set
5+
from typing import Any, Dict, List, Optional, Set
66

77
from .errors import ParseError
88
from .properties import EnumProperty, Property, property_from_dict
@@ -171,8 +171,11 @@ class Schema:
171171
@staticmethod
172172
def from_dict(d: Dict[str, Any], name: str) -> Schema:
173173
""" A single Schema from its dict representation
174-
:param d: Dict representation of the schema
175-
:param name: Name by which the schema is referenced, such as a model name. Used to infer the type name if a `title` property is not available.
174+
175+
Args:
176+
d: Dict representation of the schema
177+
name: Name by which the schema is referenced, such as a model name.
178+
Used to infer the type name if a `title` property is not available.
176179
"""
177180
required_set = set(d.get("required", []))
178181
required_properties: List[Property] = []

openapi_python_client/openapi_parser/properties.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ def get_imports(self, *, prefix: str) -> Set[str]:
9797
prefix: A prefix to put before any relative (local) module names.
9898
"""
9999
imports = super().get_imports(prefix=prefix)
100-
imports.update(
101-
{"from datetime import datetime", "from typing import cast",}
102-
)
100+
imports.update({"from datetime import datetime", "from typing import cast"})
103101
return imports
104102

105103

@@ -118,9 +116,7 @@ def get_imports(self, *, prefix: str) -> Set[str]:
118116
prefix: A prefix to put before any relative (local) module names.
119117
"""
120118
imports = super().get_imports(prefix=prefix)
121-
imports.update(
122-
{"from datetime import date", "from typing import cast",}
123-
)
119+
imports.update({"from datetime import date", "from typing import cast"})
124120
return imports
125121

126122

@@ -286,11 +282,11 @@ def get_imports(self, *, prefix: str) -> Set[str]:
286282
return imports
287283

288284
@staticmethod
289-
def values_from_list(l: List[str]) -> Dict[str, str]:
285+
def values_from_list(values: List[str]) -> Dict[str, str]:
290286
""" Convert a list of values into dict of {name: value} """
291287
output: Dict[str, str] = {}
292288

293-
for i, value in enumerate(l):
289+
for i, value in enumerate(values):
294290
if value[0].isalpha():
295291
key = value.upper()
296292
else:

poetry.lock

Lines changed: 58 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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ pytest-cov = "*"
4545
fastapi = "*"
4646
uvicorn = "*"
4747
python-multipart = "*"
48+
flake8 = "^3.8.3"
4849

4950
[tool.taskipy.tasks]
5051
check = """
5152
isort .\
5253
&& black .\
53-
&& safety check\
54+
&& flake8 openapi_python_client\
55+
&& safety check --bare\
5456
&& mypy openapi_python_client\
5557
&& pytest --cov openapi_python_client tests\
5658
"""

0 commit comments

Comments
 (0)