Skip to content

Commit

Permalink
Automated pre-commit update
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcodgen authored and github-actions[bot] committed Feb 25, 2025
1 parent 1e754e4 commit 6f8fa89
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
11 changes: 5 additions & 6 deletions src/codegen/sdk/core/import_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,15 +342,14 @@ def _imported_symbol(self, resolve_exports: bool = False) -> Symbol | ExternalMo
if self.import_type == ImportType.NAMED_EXPORT:
if export := symbol.valid_import_names.get(name, None):
return export
elif resolve_exports and isinstance(symbol,PyFile):
elif resolve_exports and isinstance(symbol, PyFile):
name = self.symbol_name.source if self.symbol_name else ""
if self.import_type == ImportType.NAMED_EXPORT:
if symbol.name==name:
if symbol.name == name:
return symbol
if imp:= symbol.valid_import_names.get(name,None):
if imp := symbol.valid_import_names.get(name, None):
return imp


if symbol is not self:
return symbol

Expand Down Expand Up @@ -642,8 +641,8 @@ def _compute_dependencies(self, *args, **kwargs) -> None:
# if used_frame.parent_frame:
# used_frame.parent_frame.add_usage(self.symbol_name or self.module, SymbolUsageType.IMPORTED_WILDCARD, self, self.ctx)
# else:
if isinstance(self, Import) and self.import_type==ImportType.NAMED_EXPORT:
#It could be a wildcard import downstream, hence we have to pop the cache
if isinstance(self, Import) and self.import_type == ImportType.NAMED_EXPORT:
# It could be a wildcard import downstream, hence we have to pop the cache
if file := self.from_file:
file.invalidate()

Expand Down
4 changes: 2 additions & 2 deletions src/codegen/sdk/python/import_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def resolve_import(self, base_path: str | None = None, *, add_module_name: str |
if file := self.ctx.get_file(filepath):
symbol = file.get_node_by_name(symbol_name)
if symbol is None:
return ImportResolution(from_file=file, symbol=None,imports_file=True)
return ImportResolution(from_file=file, symbol=None, imports_file=True)
else:
return ImportResolution(from_file=file, symbol=symbol)

Expand All @@ -128,7 +128,7 @@ def resolve_import(self, base_path: str | None = None, *, add_module_name: str |
if from_file := self.ctx.get_file(filepath):
symbol = from_file.get_node_by_name(symbol_name)
if symbol is None:
return ImportResolution(from_file=from_file, symbol=None,imports_file=True)
return ImportResolution(from_file=from_file, symbol=None, imports_file=True)
else:
return ImportResolution(from_file=from_file, symbol=symbol)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -608,14 +608,17 @@ def test_import_resolution_init_wildcard_chainging_deep(tmpdir: str) -> None:
content3 = """from .dir import *"""
content4 = """from .dir import TEST_CONST
test1=TEST_CONST"""
with get_codebase_session(tmpdir=tmpdir, files={
"dir/dir/dir/dir/file1.py": content1,
"dir/dir/dir/dir/__init__.py": content2,
"dir/dir/dir/__init__.py": content3,
"dir/dir/__init__.py": content3,
"dir/__init__.py": content3,
"file2.py": content4
}) as codebase:
with get_codebase_session(
tmpdir=tmpdir,
files={
"dir/dir/dir/dir/file1.py": content1,
"dir/dir/dir/dir/__init__.py": content2,
"dir/dir/dir/__init__.py": content3,
"dir/dir/__init__.py": content3,
"dir/__init__.py": content3,
"file2.py": content4,
},
) as codebase:
file1: SourceFile = codebase.get_file("dir/dir/dir/dir/file1.py")
file2: SourceFile = codebase.get_file("file2.py")

Expand Down

0 comments on commit 6f8fa89

Please sign in to comment.