Skip to content

Commit bb25b38

Browse files
authored
Merge pull request #92 from DavidCEllis/fix-315-argparsing
Fix `--help` in the command line on Python 3.15
2 parents e8556de + 150349c commit bb25b38

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/ducktools/pythonfinder/__main__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class FixedArgumentParser(_laz.argparse.ArgumentParser): # type: ignore
9696
This prevents the unnecessary import.
9797
"""
9898

99-
def _get_formatter(self):
99+
def _get_formatter(self, file=None, *args, **kwargs):
100100
# Calculate width
101101
try:
102102
columns = int(os.environ['COLUMNS'])
@@ -110,7 +110,13 @@ def _get_formatter(self):
110110
columns = size.columns
111111

112112
# noinspection PyArgumentList
113-
return self.formatter_class(prog=self.prog, width=columns - 2)
113+
formatter = self.formatter_class(prog=self.prog, width=columns - 2)
114+
if sys.version_info >= (3, 15): #
115+
formatter._set_color(self.color, file=file)
116+
elif sys.version_info >= (3, 14):
117+
formatter._set_color(self.color)
118+
119+
return formatter
114120

115121
return FixedArgumentParser
116122

uv.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)