Skip to content
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

patch 2 #3

Merged
merged 4 commits into from
Feb 12, 2022
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
3 changes: 2 additions & 1 deletion stubdoc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from argparse import ArgumentParser
from argparse import Namespace
import os
import importlib

from stubdoc import stubdoc

Expand Down Expand Up @@ -121,7 +122,7 @@ def _validate_module_path_arg(module_path_arg: Optional[str]) -> None:
if not os.path.isfile(module_path_arg):
raise ValueError(
f'Specified module not found: {module_path_arg}')
if not os.path.splitext(module_path_arg)[1] in ['.py', '.pyd']:
if not any(module_path_arg.endswith(ending) for ending in importlib.machinery.all_suffixes()):
raise ValueError(
f'A non-python module path specified: {module_path_arg}')

Expand Down
6 changes: 5 additions & 1 deletion stubdoc/stubdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,11 @@ def _read_module(module_path: str) -> ModuleType:
file_name: str = os.path.basename(module_path)
dir_path: str = module_path.replace(file_name, '', 1)
sys.path.append(dir_path)
package_name: str = os.path.splitext(module_path)[0]
package_name: str = None
for ending in importlib.machinery.all_suffixes():
if module_path.endswith(ending):
package_name = module_path[:-len(ending)]
break
package_name = package_name.replace('/', '.')
package_name = package_name.replace('\\', '.')
while package_name.startswith('.'):
Expand Down