Skip to content

Commit a87d17d

Browse files
author
tomcodgen
authored
fix: lint (#657)
# Motivation <!-- Why is this change necessary? --> # Content <!-- Please include a summary of the change --> # Testing <!-- How was the change tested? --> # Please check the following before marking your PR as ready for review - [ ] I have added tests for my changes - [ ] I have updated the documentation or added new documentation as needed
1 parent 66ad2c6 commit a87d17d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/codegen/sdk/python/import_resolution.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from codegen.sdk.core.node_id_factory import NodeId
2020
from codegen.sdk.core.statements.import_statement import ImportStatement
2121
from codegen.sdk.python.file import PyFile
22+
from src.codegen.sdk.core.file import SourceFile
2223

2324
import logging
2425

@@ -185,7 +186,7 @@ def resolve_import(self, base_path: str | None = None, *, add_module_name: str |
185186
@reader
186187
def _file_by_custom_resolve_paths(self, resolve_paths: list[str], filepath: str) -> SourceFile | None:
187188
"""Check if a certain file import can be found within a set sys.path
188-
189+
189190
Returns either None or the SourceFile.
190191
"""
191192
for resolve_path in resolve_paths:

tests/unit/codegen/sdk/python/import_resolution/test_import_resolution.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
from typing import TYPE_CHECKING
32

43
from codegen.sdk.codebase.factory.get_session import get_codebase_session
@@ -290,7 +289,7 @@ def func():
290289
# =====[ Imports can be found with sys.path set and active ]=====
291290
codebase.ctx.config.py_resolve_syspath = True
292291
src_import_resolution = src_import.resolve_import()
293-
assert src_import_resolution
292+
assert src_import_resolution
294293
assert src_import_resolution.from_file is src_file
295294
assert src_import_resolution.imports_file is True
296295

@@ -331,15 +330,15 @@ def func():
331330
# =====[ Imports can be found with custom resolve path set ]=====
332331
codebase.ctx.config.import_resolution_paths = ["a"]
333332
src_import_resolution = src_import.resolve_import()
334-
assert src_import_resolution
333+
assert src_import_resolution
335334
assert src_import_resolution.from_file is src_file
336335
assert src_import_resolution.imports_file is True
337336

338337
# =====[ Imports can be found with custom resolve multi-path set ]=====
339338
src_import = consumer_file.imports[1]
340339
codebase.ctx.config.import_resolution_paths = ["a/b"]
341340
src_import_resolution = src_import.resolve_import()
342-
assert src_import_resolution
341+
assert src_import_resolution
343342
assert src_import_resolution.from_file is src_file
344343
assert src_import_resolution.imports_file is True
345344

@@ -379,13 +378,13 @@ def func():
379378
monkeypatch.syspath_prepend("a")
380379
src_import: Import = consumer_file.imports[0]
381380
src_import_resolution = src_import.resolve_import()
382-
assert src_import_resolution
381+
assert src_import_resolution
383382
assert src_import_resolution.from_file.file_path == "a/c/src.py"
384383

385384
# =====[ Imports can be found with custom resolve over sys.path ]=====
386385
codebase.ctx.config.import_resolution_paths = ["a/b"]
387386
src_import_resolution = src_import.resolve_import()
388-
assert src_import_resolution
387+
assert src_import_resolution
389388
assert src_import_resolution.from_file is src_file
390389
assert src_import_resolution.imports_file is True
391390

@@ -424,20 +423,20 @@ def func():
424423
assert len(consumer_file.imports) == 1
425424
src_import: Import = consumer_file.imports[0]
426425
src_import_resolution = src_import.resolve_import()
427-
assert src_import_resolution
426+
assert src_import_resolution
428427
assert src_import_resolution.from_file is src_file
429428

430429
# =====[ Sys.path overrite has precedence ]=====
431430
monkeypatch.syspath_prepend("b")
432431
src_import_resolution = src_import.resolve_import()
433-
assert src_import_resolution
432+
assert src_import_resolution
434433
assert src_import_resolution.from_file is not src_file
435434
assert src_import_resolution.from_file is src_file_overrite
436435

437436
# =====[ Custom overrite has precedence ]=====
438437
codebase.ctx.config.import_resolution_paths = ["b"]
439438
src_import_resolution = src_import.resolve_import()
440-
assert src_import_resolution
439+
assert src_import_resolution
441440
assert src_import_resolution.from_file is not src_file
442441
assert src_import_resolution.from_file is src_file_overrite
443442

0 commit comments

Comments
 (0)