Skip to content

Commit 2c71af4

Browse files
committed
Fixed issue with argparse
1 parent 32ffd91 commit 2c71af4

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
os: [ubuntu-latest]
22-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
22+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2323
steps:
2424
- uses: actions/checkout@v3
2525
- name: Set up Python ${{ matrix.python-version }}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ dependencies = [
5252
"pathlib2",
5353
"pip>=24.0",
5454
"plyer>=2.0.0",
55-
"pydyf>=0.8.0,<0.11.0; python_version=='3.8'",
55+
"pydyf>=0.11.0",
5656
"pygments>=2.8.1",
5757
"pyminizip",
5858
"pynput",

src/tinyscript/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.30.19
1+
1.30.20

src/tinyscript/argreparse.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,37 @@ def parse_args(self, args=None, namespace=None, **kwargs):
737737
self._namespace._command = join(self._tokens)
738738
return self._namespace
739739

740+
def parse_known_args(self, args=None, namespace=None):
741+
args = _sys.argv[1:] if args is None else list(args)
742+
# default Namespace built from parser defaults
743+
if namespace is None:
744+
namespace = Namespace(self)
745+
# add any action defaults that aren't present
746+
for action in self._actions:
747+
if action.dest is not SUPPRESS:
748+
if not hasattr(namespace, action.dest):
749+
if action.default is not SUPPRESS:
750+
setattr(namespace, action.dest, action.default)
751+
# add any parser defaults that aren't present
752+
for dest in self._defaults:
753+
if not hasattr(namespace, dest):
754+
setattr(namespace, dest, self._defaults[dest])
755+
# parse the arguments and exit if there are any errors
756+
if self.exit_on_error:
757+
try:
758+
namespace, args = self._parse_known_args(args, namespace)
759+
except ArgumentError as err:
760+
self.error(str(err))
761+
else:
762+
namespace, args = self._parse_known_args(args, namespace)
763+
if hasattr(namespace, _UNRECOGNIZED_ARGS_ATTR):
764+
args.extend(set(getattr(namespace, _UNRECOGNIZED_ARGS_ATTR)))
765+
try:
766+
delattr(namespace, _UNRECOGNIZED_ARGS_ATTR)
767+
except:
768+
pass
769+
return namespace, args
770+
740771
def print_extended_help(self, level=1, file=None):
741772
if not isinstance(self.details, (tuple, list, set)):
742773
self.details = [self.details]

0 commit comments

Comments
 (0)