Skip to content

Commit

Permalink
Let ast.parse deal with encoding issues.
Browse files Browse the repository at this point in the history
Fixes #4
  • Loading branch information
jaraco committed Aug 31, 2024
1 parent b8fd744 commit cd841c6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _check_standard(top_level_name):


@functools.singledispatch
def get_module_imports(module: pathlib.Path | str) -> Generator[str]:
def get_module_imports(module: pathlib.Path | str | bytes) -> Generator[str]:
r"""
Parse a Python module to extract imported names.
Expand Down Expand Up @@ -105,7 +105,7 @@ def get_module_imports(module: pathlib.Path | str) -> Generator[str]:

@get_module_imports.register
def _(module: pathlib.Path):
return get_module_imports(module.read_text())
return get_module_imports(module.read_bytes())


def print_module_imports(path: pathlib.Path):
Expand Down

0 comments on commit cd841c6

Please sign in to comment.