Skip to content

Commit

Permalink
fix: don't use sys.orig_argv
Browse files Browse the repository at this point in the history
  • Loading branch information
likianta committed Feb 18, 2025
1 parent aa490da commit 57abec3
Show file tree
Hide file tree
Showing 7 changed files with 1,210 additions and 29 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.zh.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 更新日志

### 0.7.1 (wip)

...

### 0.7.0 (2025-02-08)

- 非侵入式调用脚本
Expand Down
2 changes: 1 addition & 1 deletion argsense/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
from .parser import parse_docstring
from .parser import parse_function

__version__ = '0.7.0'
__version__ = '0.7.1'
7 changes: 2 additions & 5 deletions argsense/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,11 @@ def decorator(func: T.Func) -> T.Func:
def run(self, func: T.Func = None, transport_help: bool = False) -> t.Any:
config.apply_changes()
return self.exec_argv(
argv=Argv.from_sys_argv(
sys.orig_argv if hasattr(sys, 'orig_argv') else
(sys.executable, *sys.argv)
),
argv=Argv.from_sys_argv((sys.executable, *sys.argv)),
preset_func=func,
transport_help=transport_help,
)

def exec_argv(
self,
argv: Argv,
Expand Down
6 changes: 4 additions & 2 deletions argsense/parser/args_parser/argv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import rich
import rich.panel

# print(sys.argv, ':v')

_DEBUG = os.getenv('ARGSENSE_DEBUG') == '1'
if _DEBUG:
print(sys.orig_argv, sys.argv, ':lv')


class T:
Expand Down Expand Up @@ -40,6 +40,8 @@ def from_sys_argv(cls, argv: t.Sequence[str]) -> 'Argv':
['python', 'test.py', 'foo', '--bar', 'baz']
['python', '-m', 'test', 'foo', '--bar', 'baz']
FIXME: don't use `sys.orig_argv`, use `sys.argv`.
returns:
e.g.
Argv(
Expand Down
Loading

0 comments on commit 57abec3

Please sign in to comment.