Skip to content

Commit 1fa7e97

Browse files
committed
Address new Ruff lints
1 parent aca2732 commit 1fa7e97

File tree

17 files changed

+45
-194
lines changed

17 files changed

+45
-194
lines changed

openapi_python_client/cli.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@
66

77
import typer
88

9-
from openapi_python_client import MetaType
9+
from openapi_python_client import MetaType, __version__
1010
from openapi_python_client.config import Config, ConfigFile
1111
from openapi_python_client.parser.errors import ErrorLevel, GeneratorError, ParseError
1212

1313
app = typer.Typer(name="openapi-python-client")
1414

1515

1616
def _version_callback(value: bool) -> None:
17-
from openapi_python_client import __version__
18-
1917
if value:
2018
typer.echo(f"openapi-python-client version: {__version__}")
2119
raise typer.Exit()
@@ -153,7 +151,7 @@ def generate(
153151
),
154152
) -> None:
155153
"""Generate a new OpenAPI Client library"""
156-
from . import generate
154+
from . import generate # noqa: PLC0415
157155

158156
config = _process_config(
159157
url=url,

openapi_python_client/parser/properties/any.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def build(
3333

3434
@classmethod
3535
def convert_value(cls, value: Any) -> Value | None:
36-
from .string import StringProperty
36+
from .string import StringProperty # noqa: PLC0415
3737

3838
if value is None:
3939
return value

openapi_python_client/parser/properties/list_property.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def build(
5656
`(result, schemas)` where `schemas` is an updated version of the input named the same including any inner
5757
classes that were defined and `result` is either the `ListProperty` or a `PropertyError`.
5858
"""
59-
from . import property_from_data
59+
from . import property_from_data # noqa: PLC0415
6060

6161
if data.items is None and not data.prefixItems:
6262
return (

openapi_python_client/parser/properties/model_property.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ def _process_properties( # noqa: PLR0912, PLR0911
242242
config: Config,
243243
roots: set[ReferencePath | utils.ClassName],
244244
) -> _PropertyData | PropertyError:
245-
from . import property_from_data
246-
from .merge_properties import merge_properties
245+
from . import property_from_data # noqa: PLC0415
246+
from .merge_properties import merge_properties # noqa: PLC0415
247247

248248
properties: dict[str, Property] = {}
249249
relative_imports: set[str] = set()
@@ -353,7 +353,7 @@ def _get_additional_properties(
353353
config: Config,
354354
roots: set[ReferencePath | utils.ClassName],
355355
) -> tuple[Property | None | PropertyError, Schemas]:
356-
from . import property_from_data
356+
from . import property_from_data # noqa: PLC0415
357357

358358
if schema_additional is None:
359359
return ANY_ADDITIONAL_PROPERTY, schemas

openapi_python_client/parser/properties/protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def to_docstring(self) -> str:
174174
@property
175175
def is_base_type(self) -> bool:
176176
"""Base types, represented by any other of `Property` than `ModelProperty` should not be quoted."""
177-
from . import ListProperty, ModelProperty, UnionProperty
177+
from . import ListProperty, ModelProperty, UnionProperty # noqa: PLC0415
178178

179179
return self.__class__.__name__ not in {
180180
ModelProperty.__name__,

openapi_python_client/parser/properties/schemas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def update_schemas_with_data(
118118
See Also:
119119
- https://swagger.io/docs/specification/using-ref/
120120
"""
121-
from . import property_from_data
121+
from . import property_from_data # noqa: PLC0415
122122

123123
prop: Union[PropertyError, Property]
124124
prop, schemas = property_from_data(

openapi_python_client/parser/properties/union.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def build(
4545
`(result, schemas)` where `schemas` is the updated version of the input `schemas` and `result` is the
4646
constructed `UnionProperty` or a `PropertyError` describing what went wrong.
4747
"""
48-
from . import property_from_data
48+
from . import property_from_data # noqa: PLC0415
4949

5050
sub_properties: list[PropertyProtocol] = []
5151

@@ -180,7 +180,7 @@ def get_lazy_imports(self, *, prefix: str) -> set[str]:
180180

181181
def validate_location(self, location: oai.ParameterLocation) -> ParseError | None:
182182
"""Returns an error if this type of property is not allowed in the given location"""
183-
from ..properties import Property
183+
from ..properties import Property # noqa: PLC0415
184184

185185
for inner_prop in self.inner_properties:
186186
if evolve(cast(Property, inner_prop), required=self.required).validate_location(location) is not None:

tests/conftest.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def model_property_factory() -> ModelFactory:
5656
5757
You can pass the same params into this as the ModelProperty constructor to override defaults.
5858
"""
59-
from openapi_python_client.parser.properties import Class
6059

6160
def _factory(**kwargs):
6261
kwargs = _common_kwargs(kwargs)
@@ -130,7 +129,6 @@ def enum_property_factory() -> EnumFactory[EnumProperty]:
130129
131130
You can pass the same params into this as the EnumProerty constructor to override defaults.
132131
"""
133-
from openapi_python_client.parser.properties import Class
134132

135133
return _simple_factory(
136134
EnumProperty,
@@ -149,7 +147,6 @@ def literal_enum_property_factory() -> EnumFactory[LiteralEnumProperty]:
149147
150148
You can pass the same params into this as the LiteralEnumProerty constructor to override defaults.
151149
"""
152-
from openapi_python_client.parser.properties import Class
153150

154151
return _simple_factory(
155152
LiteralEnumProperty,

tests/test___init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from unittest.mock import MagicMock
2+
13
import pytest
24

35
from openapi_python_client import Config, ErrorLevel, Project
@@ -7,10 +9,6 @@
79

810

911
def make_project(config: Config) -> Project:
10-
from unittest.mock import MagicMock
11-
12-
from openapi_python_client import Project
13-
1412
return Project(openapi=MagicMock(title="My Test API"), config=config)
1513

1614

tests/test_cli.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
from typer.testing import CliRunner
22

3+
from openapi_python_client.cli import app
4+
35
runner = CliRunner()
46

57

68
def test_version() -> None:
7-
from openapi_python_client.cli import app
8-
99
result = runner.invoke(app, ["--version", "generate"])
1010

1111
assert result.exit_code == 0
1212
assert "openapi-python-client version: " in result.stdout
1313

1414

1515
def test_bad_config() -> None:
16-
from openapi_python_client.cli import app
17-
1816
config_path = "config/path"
1917
path = "cool/path"
2018

@@ -26,15 +24,11 @@ def test_bad_config() -> None:
2624

2725
class TestGenerate:
2826
def test_generate_no_params(self) -> None:
29-
from openapi_python_client.cli import app
30-
3127
result = runner.invoke(app, ["generate"])
3228

3329
assert result.exit_code == 1, result.output
3430

3531
def test_generate_url_and_path(self) -> None:
36-
from openapi_python_client.cli import app
37-
3832
result = runner.invoke(app, ["generate", "--path=blah", "--url=otherblah"])
3933

4034
assert result.exit_code == 1
@@ -43,8 +37,6 @@ def test_generate_url_and_path(self) -> None:
4337
def test_generate_encoding_errors(self) -> None:
4438
path = "cool/path"
4539
file_encoding = "error-file-encoding"
46-
from openapi_python_client.cli import app
47-
4840
result = runner.invoke(app, ["generate", f"--path={path}", f"--file-encoding={file_encoding}"])
4941

5042
assert result.exit_code == 1

0 commit comments

Comments
 (0)