Skip to content

fix init.py bug #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/codegen/sdk/python/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from codegen.sdk.core.file import SourceFile
from codegen.sdk.core.interface import Interface
from codegen.sdk.enums import ImportType, ProgrammingLanguage
from codegen.sdk.extensions.utils import cached_property, iter_all_descendants

Check failure on line 9 in src/codegen/sdk/python/file.py

View workflow job for this annotation

GitHub Actions / mypy

error: Module "codegen.sdk.extensions.utils" does not explicitly export attribute "cached_property" [attr-defined]
from codegen.sdk.python import PyAssignment
from codegen.sdk.python.class_definition import PyClass
from codegen.sdk.python.detached_symbols.code_block import PyCodeBlock
Expand All @@ -25,7 +25,7 @@


@py_apidoc
class PyFile(SourceFile[PyImport, PyFunction, PyClass, PyAssignment, Interface[PyCodeBlock, PyAttribute, PyFunction, PyType], PyCodeBlock], PyHasBlock):

Check failure on line 28 in src/codegen/sdk/python/file.py

View workflow job for this annotation

GitHub Actions / mypy

error: Definition of "node_type" in base class "File" is incompatible with definition in base class "Expression" [misc]

Check failure on line 28 in src/codegen/sdk/python/file.py

View workflow job for this annotation

GitHub Actions / mypy

error: Variable "codegen.sdk.python.expressions.type.PyType" is not valid as a type [valid-type]
"""SourceFile representation for Python codebase

Attributes:
Expand All @@ -45,7 +45,7 @@
"""
return [".py"]

def symbol_can_be_added(self, symbol: PySymbol) -> bool:

Check failure on line 48 in src/codegen/sdk/python/file.py

View workflow job for this annotation

GitHub Actions / mypy

error: Argument 1 of "symbol_can_be_added" is incompatible with supertype "SourceFile"; supertype defines the argument type as "Symbol[Any, Any]" [override]
"""Checks if a Python symbol can be added to this Python source file.

Verifies whether a given Python symbol is compatible with and can be added to this Python source file. Currently always returns True as Python files can contain any Python symbol type.
Expand All @@ -69,7 +69,7 @@
####################################################################################################################

@noapidoc
def get_import_module_name_for_file(self, filepath: str, G: CodebaseGraph) -> str:

Check failure on line 72 in src/codegen/sdk/python/file.py

View workflow job for this annotation

GitHub Actions / mypy

error: Signature of "get_import_module_name_for_file" incompatible with supertype "SourceFile" [override]
"""Returns the module name that this file gets imported as

For example, `my/package/name.py` => `my.package.name`
Expand Down Expand Up @@ -182,17 +182,17 @@
@cached_property
@noapidoc
@reader(cache=True)
def valid_import_names(self) -> dict[str, PySymbol | PyImport | WildcardImport[PyImport]]:

Check failure on line 185 in src/codegen/sdk/python/file.py

View workflow job for this annotation

GitHub Actions / mypy

error: Signature of "valid_import_names" incompatible with supertype "SourceFile" [override]
"""Returns a dict mapping name => Symbol (or import) in this file that can be imported from
another file.
"""
if self.name == "__init__":
ret = {}
ret = super().valid_import_names
if self.directory:
for file in self.directory:
if file.name == "__init__":
continue
if isinstance(file, PyFile):
ret[file.name] = file

Check failure on line 196 in src/codegen/sdk/python/file.py

View workflow job for this annotation

GitHub Actions / mypy

error: Incompatible types in assignment (expression has type "PyFile", target has type "Symbol[Any, Any] | PyImport | WildcardImport[PyImport]") [assignment]
return ret

Check failure on line 197 in src/codegen/sdk/python/file.py

View workflow job for this annotation

GitHub Actions / mypy

error: Incompatible return value type (got "dict[str, Symbol[Any, Any] | PyImport | WildcardImport[PyImport]]", expected "dict[str, PySymbol | PyImport | WildcardImport[PyImport]]") [return-value]
return super().valid_import_names

Check failure on line 198 in src/codegen/sdk/python/file.py

View workflow job for this annotation

GitHub Actions / mypy

error: Incompatible return value type (got "dict[str, Symbol[Any, Any] | PyImport | WildcardImport[PyImport]]", expected "dict[str, PySymbol | PyImport | WildcardImport[PyImport]]") [return-value]
Loading