Skip to content

Commit 9aa3f69

Browse files
committed
Use ty in place of pytype
1 parent d33056c commit 9aa3f69

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

.github/scripts/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pip install ipython
2525
python -m pytest # Now run the tests with IPython.
2626
pylint fire --ignore=test_components_py3.py,parser_fuzz_test.py,console
2727
if [[ ${PYTHON_VERSION} == 3.7 ]]; then
28-
# Run type-checking.
29-
pip install pytype;
30-
pytype -x fire/test_components_py3.py;
28+
# Run type-checking with ty.
29+
pip install uv;
30+
uvx ty check;
3131
fi

fire/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def import_from_file_path(path):
6060

6161
spec = util.spec_from_file_location(module_name, path)
6262

63-
if spec is None:
63+
if spec is None or spec.loader is None:
6464
raise OSError('Unable to load module from specified path.')
6565

6666
module = util.module_from_spec(spec) # pylint: disable=no-member

fire/custom_descriptions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,14 @@ def GetStringTypeDescription(obj, available_space, line_length):
131131
def GetSummary(obj, available_space, line_length):
132132
obj_type_name = type(obj).__name__
133133
if obj_type_name in CUSTOM_DESC_SUM_FN_DICT:
134-
return CUSTOM_DESC_SUM_FN_DICT.get(obj_type_name)[0](obj, available_space,
135-
line_length)
134+
return CUSTOM_DESC_SUM_FN_DICT[obj_type_name][0](obj, available_space,
135+
line_length)
136136
return None
137137

138138

139139
def GetDescription(obj, available_space, line_length):
140140
obj_type_name = type(obj).__name__
141141
if obj_type_name in CUSTOM_DESC_SUM_FN_DICT:
142-
return CUSTOM_DESC_SUM_FN_DICT.get(obj_type_name)[1](obj, available_space,
143-
line_length)
142+
return CUSTOM_DESC_SUM_FN_DICT[obj_type_name][1](obj, available_space,
143+
line_length)
144144
return None

fire/helptext.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
information.
3030
"""
3131

32+
from __future__ import annotations
33+
3234
import collections
3335
import itertools
3436

@@ -91,7 +93,7 @@ def HelpText(component, trace=None, verbose=False):
9193
)
9294

9395

94-
def _NameSection(component, info, trace=None, verbose=False):
96+
def _NameSection(component, info, trace=None, verbose=False) -> tuple[str, str]:
9597
"""The "Name" section of the help string."""
9698

9799
# Only include separators in the name in verbose mode.
@@ -113,7 +115,7 @@ def _NameSection(component, info, trace=None, verbose=False):
113115

114116

115117
def _SynopsisSection(component, actions_grouped_by_kind, spec, metadata,
116-
trace=None):
118+
trace=None) -> tuple[str, str]:
117119
"""The "Synopsis" section of the help string."""
118120
current_command = _GetCurrentCommand(trace=trace, include_separators=True)
119121

@@ -136,7 +138,7 @@ def _SynopsisSection(component, actions_grouped_by_kind, spec, metadata,
136138
return ('SYNOPSIS', text)
137139

138140

139-
def _DescriptionSection(component, info):
141+
def _DescriptionSection(component, info) -> tuple[str, str] | None:
140142
"""The "Description" sections of the help string.
141143
142144
Args:
@@ -185,7 +187,7 @@ def _GetShortFlags(flags):
185187
return [v for v in short_flags if short_flag_counts[v] == 1]
186188

187189

188-
def _ArgsAndFlagsSections(info, spec, metadata):
190+
def _ArgsAndFlagsSections(info, spec, metadata) -> tuple[list[tuple[str, str]], list[tuple[str, str]]]:
189191
"""The "Args and Flags" sections of the help string."""
190192
args_with_no_defaults = spec.args[:len(spec.args) - len(spec.defaults)]
191193
args_with_defaults = spec.args[len(spec.args) - len(spec.defaults):]
@@ -408,7 +410,7 @@ def _GetCurrentCommand(trace=None, include_separators=True):
408410
return current_command
409411

410412

411-
def _CreateOutputSection(name, content):
413+
def _CreateOutputSection(name: str, content: str) -> str:
412414
return f"""{formatting.Bold(name)}
413415
{formatting.Indent(content, SECTION_INDENTATION)}"""
414416

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,5 @@ addopts = [
6464
"--ignore=fire/parser_fuzz_test.py"
6565
]
6666

67-
[tool.pytype]
68-
inputs = "."
69-
output = ".pytype"
67+
[tool.ty]
68+
# ty configuration - using defaults for now

0 commit comments

Comments
 (0)