Skip to content

Fix gradio #130

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 7 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
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 README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Codegen

![PyPI](https://img.shields.io/pypi/v/codegen?color=blue) [![Documentation](https://img.shields.io/badge/docs-docs.codegen.com-purple)](https://docs.codegen.com) [![Slack Community](https://img.shields.io/badge/slack-community-4A154B?logo=slack)](https://community.codegen.com) [![Follow on X](https://img.shields.io/twitter/follow/codegen)](https://x.com/codegen)
![PyPI](https://img.shields.io/pypi/v/codegen?color=blue) [![Documentation](https://img.shields.io/badge/docs-docs.codegen.com-purple)](https://docs.codegen.com) [![Slack Community](https://img.shields.io/badge/slack-community-4A154B?logo=slack)](https://community.codegen.com) [![Follow on X](https://img.shields.io/twitter/follow/codegen)](https://x.com/codegen)

[Codegen](https://docs.codegen.com) is a python library for manipulating codebases.

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ classifiers = [
"Topic :: Software Development :: Code Generators",
"Topic :: Software Development :: Libraries",
]
authors = [{ name = "Codegen Team", email = "team+codegenbot@codegen.sh" }]
authors = [{ name = "Codegen Team", email = "[email protected]" }]
keywords = [
"codegen",
"codebase",
Expand Down
4 changes: 4 additions & 0 deletions src/codegen/sdk/core/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,10 @@ def valid_symbol_names(self) -> dict[str, Symbol | TImport | WildcardImport[TImp
@reader
def resolve_name(self, name: str, start_byte: int | None = None) -> Symbol | Import | WildcardImport | None:
if resolved := self.valid_symbol_names.get(name):
if start_byte is not None and resolved.end_byte > start_byte:
for symbol in self.symbols:
if symbol.start_byte <= start_byte and symbol.name == name:
return symbol
return resolved

@property
Expand Down
1 change: 1 addition & 0 deletions src/codegen/sdk/core/import_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ class WildcardImport(Chainable, Generic[TImport]):
def __init__(self, imp: TImport, symbol: Importable):
self.imp = imp
self.symbol = symbol
self.ts_node = imp.ts_node

@reader
@noapidoc
Expand Down
9 changes: 8 additions & 1 deletion src/codegen/sdk/core/interfaces/importable.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from typing import TYPE_CHECKING, Generic, Self, TypeVar, Union

from tree_sitter import Node as TSNode
Expand All @@ -20,6 +21,8 @@

Parent = TypeVar("Parent", bound="Editable")

logger = logging.getLogger(__name__)


@apidoc
class Importable(Expression[Parent], HasName, Generic[Parent]):
Expand Down Expand Up @@ -90,7 +93,11 @@ def recompute(self, incremental: bool = False) -> list["Importable"]:
"""
if incremental:
self._remove_internal_edges(EdgeType.SYMBOL_USAGE)
self._compute_dependencies()
try:
self._compute_dependencies()
except Exception as e:
logger.error(f"Error in file {self.file.path} while computing dependencies for symbol {self.name}")
raise e
if incremental:
return self.descendant_symbols + self.file.get_nodes(sort=False)
return []
Expand Down
7 changes: 7 additions & 0 deletions tests/integration/codemod/repos/open_source/gradio.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "gradio",
"commit": "f40747c9fd12d160ac9f7b3c5273be6be815efac",
"url": "https://github.com/gradio-app/gradio",
"language": "PYTHON",
"size": "small"
}
4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.