Skip to content

Commit 219747c

Browse files
h-joocopybara-github
authored andcommitted
Automated Code Change
PiperOrigin-RevId: 941604731
1 parent 55cec10 commit 219747c

39 files changed

Lines changed: 191 additions & 191 deletions

openhtf/core/diagnoses_lib.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def execute_phase_diagnoser(self, diagnoser: 'BasePhaseDiagnoser',
229229
test_rec: test_record.TestRecord, the current running test's record.
230230
"""
231231
diagnosis_or_diagnoses = diagnoser.run(phase_state.phase_record)
232-
for diag in self._convert_result(diagnosis_or_diagnoses, diagnoser):
232+
for diag in self._convert_result(diagnosis_or_diagnoses, diagnoser): # pyrefly: ignore[bad-argument-type]
233233
phase_state.add_diagnosis(diag)
234234
# Internal diagnosers are not saved to the test record because they are
235235
# not serialized.
@@ -249,7 +249,7 @@ def execute_test_diagnoser(self, diagnoser: 'BaseTestDiagnoser',
249249
InvalidDiagnosisError: when the diagnoser returns an Internal diagnosis.
250250
"""
251251
diagnosis_or_diagnoses = diagnoser.run(test_rec, self.store)
252-
for diag in self._convert_result(diagnosis_or_diagnoses, diagnoser):
252+
for diag in self._convert_result(diagnosis_or_diagnoses, diagnoser): # pyrefly: ignore[bad-argument-type]
253253
if diag.is_internal:
254254
raise InvalidDiagnosisError(
255255
'Test-level diagnosis {} cannot be Internal'.format(diag))
@@ -315,7 +315,7 @@ def as_base_types(self) -> Dict[Text, Any]:
315315
'possible_results': self.possible_results,
316316
}
317317
if self.always_fail:
318-
ret.update(always_fail=True)
318+
ret.update(always_fail=True) # pyrefly: ignore[bad-argument-type]
319319
return ret
320320

321321
@property
@@ -326,7 +326,7 @@ def _check_definition(self) -> None:
326326
"""Internal function to verify that the diagnoser is completely defined."""
327327

328328

329-
class BasePhaseDiagnoser(_BaseDiagnoser, abc.ABC):
329+
class BasePhaseDiagnoser(_BaseDiagnoser, abc.ABC): # pyrefly: ignore[bad-class-definition]
330330
"""Base class for using an object to define a Phase diagnoser."""
331331

332332
__slots__ = ()
@@ -362,20 +362,20 @@ def __call__(
362362
'Fully defined diagnoser cannot decorate another function.')
363363
changes = dict(run_func=func)
364364
if not self.name:
365-
changes['name'] = func.__name__
365+
changes['name'] = func.__name__ # pyrefly: ignore[bad-assignment]
366366
return attr.evolve(self, **changes)
367367

368368
def run(self, phase_record: test_record.PhaseRecord) -> DiagnoserReturnT:
369369
"""Runs the phase diagnoser and returns the diagnoses."""
370-
return self._run_func(phase_record)
370+
return self._run_func(phase_record) # pyrefly: ignore[not-callable]
371371

372372
def _check_definition(self) -> None:
373373
if not self._run_func:
374374
raise DiagnoserError(
375375
'PhaseDiagnoser run function not defined for {}'.format(self.name))
376376

377377

378-
class BaseTestDiagnoser(_BaseDiagnoser, abc.ABC):
378+
class BaseTestDiagnoser(_BaseDiagnoser, abc.ABC): # pyrefly: ignore[bad-class-definition]
379379
"""Base class for using an object to define a Test diagnoser."""
380380

381381
__slots__ = ()
@@ -416,13 +416,13 @@ def __call__(
416416
'Fully defined diagnoser cannot decorate another function.')
417417
changes = dict(run_func=func)
418418
if not self.name:
419-
changes['name'] = func.__name__
419+
changes['name'] = func.__name__ # pyrefly: ignore[bad-assignment]
420420
return attr.evolve(self, **changes)
421421

422422
def run(self, test_rec: test_record.TestRecord,
423423
diagnoses_store: DiagnosesStore) -> DiagnoserReturnT:
424424
"""Runs the test diagnoser and returns the diagnoses."""
425-
return self._run_func(test_rec, diagnoses_store)
425+
return self._run_func(test_rec, diagnoses_store) # pyrefly: ignore[not-callable]
426426

427427
def _check_definition(self) -> None:
428428
if not self._run_func:

openhtf/core/measurements.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class Measurement(object):
236236
_cached = attr.ib(type=Optional[Dict[Text, Any]], default=None)
237237

238238
def __attrs_pre_init__(self, name: Text, *args: Any, **kwargs: Any) -> None:
239-
del(args, kwargs)
239+
del(args, kwargs) # pyrefly: ignore[unsupported-delete]
240240
if name in _RESERVED_MEASUREMENT_NAMES:
241241
raise ReservedMeasurementNameError(
242242
f'Measurement name {name} is reserved for internal use.'
@@ -308,7 +308,7 @@ def set_notification_callback(
308308
"""Set the notifier we'll call when measurements are set."""
309309
self._notification_cb = notification_cb
310310
if not notification_cb and self.dimensions:
311-
self._measured_value.notify_value_set = None
311+
self._measured_value.notify_value_set = None # pyrefly: ignore[missing-attribute]
312312
return self
313313

314314
def notify_value_set(self) -> None:
@@ -495,7 +495,7 @@ def to_dataframe(self, columns: Any = None) -> Any:
495495
'Only a dimensioned measurement can be converted to a DataFrame')
496496

497497
if columns is None:
498-
columns = [d.name for d in self.dimensions]
498+
columns = [d.name for d in self.dimensions] # pyrefly: ignore[not-iterable]
499499
columns += [self.units.name if self.units else 'value']
500500

501501
dataframe = self._measured_value.to_dataframe(columns)
@@ -518,7 +518,7 @@ def from_dataframe(self, dataframe: Any, metric_column: str) -> None:
518518
raise TypeError(
519519
'Only a dimensioned measurement can be set from a DataFrame'
520520
)
521-
dimension_labels = [d.name for d in self.dimensions]
521+
dimension_labels = [d.name for d in self.dimensions] # pyrefly: ignore[not-iterable]
522522
dimensioned_df = dataframe.reset_index()
523523
try:
524524
dimensioned_df.set_index(dimension_labels, inplace=True)
@@ -561,12 +561,12 @@ class MeasuredValue(object):
561561
def __str__(self) -> Text:
562562
return str(self.value) if self.is_value_set else 'UNSET'
563563

564-
def __eq__(self, other: 'MeasuredValue') -> bool:
564+
def __eq__(self, other: 'MeasuredValue') -> bool: # pyrefly: ignore[bad-override]
565565
return (type(self) == type(other) and self.name == other.name and # pylint: disable=unidiomatic-typecheck
566566
self.is_value_set == other.is_value_set
567567
and self.stored_value == other.stored_value)
568568

569-
def __ne__(self, other: 'MeasuredValue') -> bool:
569+
def __ne__(self, other: 'MeasuredValue') -> bool: # pyrefly: ignore[bad-override]
570570
return not self.__eq__(other)
571571

572572
@property
@@ -621,10 +621,10 @@ def __attrs_post_init__(self) -> None:
621621
'suffix': self.suffix,
622622
})
623623

624-
def __eq__(self, other: 'Dimension') -> bool:
624+
def __eq__(self, other: 'Dimension') -> bool: # pyrefly: ignore[bad-override]
625625
return self.description == other.description and self.unit == other.unit
626626

627-
def __ne__(self, other: 'Dimension') -> bool:
627+
def __ne__(self, other: 'Dimension') -> bool: # pyrefly: ignore[bad-override]
628628
return not self == other
629629

630630
def __repr__(self) -> Text:
@@ -633,17 +633,17 @@ def __repr__(self) -> Text:
633633
@classmethod
634634
def from_unit_descriptor(cls,
635635
unit_desc: util_units.UnitDescriptor) -> 'Dimension':
636-
return cls(unit=unit_desc)
636+
return cls(unit=unit_desc) # pyrefly: ignore[unexpected-keyword]
637637

638638
@classmethod
639639
def from_string(cls, string: Text) -> 'Dimension':
640640
"""Convert a string into a Dimension."""
641641
# Note: There is some ambiguity as to whether the string passed is intended
642642
# to become a unit looked up by name or suffix, or a Dimension descriptor.
643643
if string in util_units.UNITS_BY_ALL:
644-
return cls(description=string, unit=util_units.Unit(string))
644+
return cls(description=string, unit=util_units.Unit(string)) # pyrefly: ignore[unexpected-keyword]
645645
else:
646-
return cls(description=string)
646+
return cls(description=string) # pyrefly: ignore[unexpected-keyword]
647647

648648
@property
649649
def description(self) -> Text:
@@ -729,7 +729,7 @@ def __setitem__(self, coordinates: Any, value: Any) -> None:
729729
_LOG.warning(
730730
'Overriding previous measurement %s[%s] value of %s with %s',
731731
self.name, coordinates, self.value_dict[coordinates], value)
732-
self._cached_basetype_values = None
732+
self._cached_basetype_values = None # pyrefly: ignore[bad-assignment]
733733
elif self._cached_basetype_values is not None:
734734
self._cached_basetype_values.append(
735735
data.convert_to_base_types(coordinates + (value,)))
@@ -774,7 +774,7 @@ def value(self) -> List[Any]:
774774

775775
def basetype_value(self) -> List[Any]:
776776
if self._cached_basetype_values is None:
777-
self._cached_basetype_values = list(
777+
self._cached_basetype_values = list( # pyrefly: ignore[bad-assignment]
778778
data.convert_to_base_types(coordinates + (value,))
779779
for coordinates, value in self.value_dict.items())
780780
return self._cached_basetype_values

openhtf/core/phase_collections.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def _recursive_flatten(n: Any) -> Iterator[phase_nodes.PhaseNode]:
5151
elif isinstance(n, phase_nodes.PhaseNode):
5252
yield n.copy()
5353
elif isinstance(n, phase_descriptor.PhaseDescriptor) or callable(n):
54-
yield phase_descriptor.PhaseDescriptor.wrap_or_copy(n)
54+
yield phase_descriptor.PhaseDescriptor.wrap_or_copy(n) # pyrefly: ignore[bad-argument-type]
5555
else:
5656
raise ValueError('Cannot flatten {}'.format(n))
5757

@@ -225,7 +225,7 @@ def check_for_duplicate_subtest_names(sequence: PhaseSequence):
225225
collections.defaultdict(list)
226226
)
227227
for subtest in sequence.filter_by_type(Subtest):
228-
names_to_subtests[subtest.name].append(subtest)
228+
names_to_subtests[subtest.name].append(subtest) # pyrefly: ignore[bad-index]
229229

230230
duplicates: list[str] = []
231231
for name, subtests in names_to_subtests.items():

openhtf/core/phase_descriptor.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class PhaseDescriptor(phase_nodes.PhaseNode):
200200
func = attr.ib(type=PhaseCallableT)
201201
func_location = attr.ib(type=Text)
202202

203-
@func_location.default
203+
@func_location.default # pyrefly: ignore[missing-attribute]
204204
def _func_location(self):
205205
"""Assigns this field assuming func is a function or callable instance."""
206206
obj = self.func
@@ -215,7 +215,7 @@ def _func_location(self):
215215
return '<unknown>'
216216
obj = obj.__class__
217217
try:
218-
filename = os.path.basename(inspect.getsourcefile(obj))
218+
filename = os.path.basename(inspect.getsourcefile(obj)) # pyrefly: ignore[no-matching-overload]
219219
line_number = inspect.getsourcelines(obj)[1]
220220
except TypeError:
221221
return name + ' <builtin>'
@@ -256,7 +256,7 @@ def wrap_or_copy(cls, func: PhaseT, **options: Any) -> 'PhaseDescriptor':
256256
# or kwargs. See with_args() below for more details.
257257
retval = data.attr_copy(func)
258258
else:
259-
retval = cls(func)
259+
retval = cls(func) # pyrefly: ignore[missing-argument]
260260
retval.options.update(**options)
261261
return retval
262262

@@ -390,7 +390,7 @@ def __call__(self,
390390
kwargs.update(self.extra_kwargs)
391391
kwargs.update(
392392
running_test_state.plug_manager.provide_plugs(
393-
(plug.name, plug.cls) for plug in self.plugs if plug.update_kwargs))
393+
(plug.name, plug.cls) for plug in self.plugs if plug.update_kwargs)) # pyrefly: ignore[bad-argument-type]
394394

395395
# Pass in test_api if the phase takes *args, or **kwargs with at least 1
396396
# positional, or more positional args than we have keyword args.
@@ -460,20 +460,20 @@ def _maybe_make(
460460
if 'outcome' in kwargs:
461461
raise ValueError('Cannot specify outcome in measurement declaration!')
462462

463-
measurements = [_maybe_make(meas) for meas in measurements]
463+
measurements = [_maybe_make(meas) for meas in measurements] # pyrefly: ignore[bad-assignment]
464464

465465
# 'measurements' is guaranteed to be a list of Measurement objects here.
466466
def decorate(wrapped_phase: PhaseT) -> PhaseDescriptor:
467467
"""Phase decorator to be returned."""
468468
phase = PhaseDescriptor.wrap_or_copy(wrapped_phase)
469469
duplicate_names = (
470-
set(m.name for m in measurements)
470+
set(m.name for m in measurements) # pyrefly: ignore[missing-attribute]
471471
& set(m.name for m in phase.measurements))
472472
if duplicate_names:
473473
raise core_measurements.DuplicateNameError('Measurement names duplicated',
474474
duplicate_names)
475475

476-
phase.measurements.extend(measurements)
476+
phase.measurements.extend(measurements) # pyrefly: ignore[bad-argument-type]
477477
return phase
478478

479479
return decorate

openhtf/core/phase_executor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def _log_exception(self, *args: Any) -> Any:
191191
"""Log exception, while allowing unit testing to override."""
192192
self._test_state.state_logger.critical(*args)
193193

194-
def _thread_exception(self, *args) -> bool:
194+
def _thread_exception(self, *args) -> bool: # pyrefly: ignore[bad-override]
195195
self._phase_execution_outcome = PhaseExecutionOutcome(ExceptionInfo(*args))
196196
self._log_exception('Phase %s raised an exception', self._phase_desc.name)
197197
return True # Never propagate exceptions upward.
@@ -222,7 +222,7 @@ def join_or_die(self) -> PhaseExecutionOutcome:
222222
return PhaseExecutionOutcome(threads.ThreadTerminationError())
223223

224224
@property
225-
def name(self) -> Text:
225+
def name(self) -> Text: # pyrefly: ignore[bad-override]
226226
return str(self)
227227

228228
def __str__(self) -> Text:
@@ -349,7 +349,7 @@ def _execute_phase_once(
349349
self._current_phase_thread = phase_thread
350350

351351
phase_state.result = phase_thread.join_or_die()
352-
if phase_state.result.is_repeat and is_last_repeat:
352+
if phase_state.result.is_repeat and is_last_repeat: # pyrefly: ignore[missing-attribute]
353353
self.logger.error('Phase returned REPEAT, exceeding repeat_limit.')
354354
phase_state.hit_repeat_limit = True
355355
override_result = PhaseExecutionOutcome(
@@ -360,8 +360,8 @@ def _execute_phase_once(
360360
# or phase diagnoser raised an exception.
361361
result = override_result or phase_state.result
362362
self.logger.debug('Phase %s finished with result %r', phase_desc.name,
363-
result.phase_result)
364-
return (result,
363+
result.phase_result) # pyrefly: ignore[missing-attribute]
364+
return (result, # pyrefly: ignore[bad-return]
365365
phase_thread.get_profile_stats() if run_with_profiling else None)
366366

367367
def skip_phase(self, phase_desc: phase_descriptor.PhaseDescriptor,

openhtf/core/test_descriptor.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def trigger_phase(test):
324324
trigger = test_start
325325

326326
if CONF.capture_source:
327-
trigger.code_info = htf_test_record.CodeInfo.for_function(trigger.func)
327+
trigger.code_info = htf_test_record.CodeInfo.for_function(trigger.func) # pyrefly: ignore[missing-attribute]
328328

329329
self._executor = test_executor.TestExecutor(
330330
self._test_desc,
@@ -359,7 +359,7 @@ def trigger_phase(test):
359359
_LOG.debug('Test completed for %s, outputting now.',
360360
final_state.test_record.metadata['test_name'])
361361
test_executor.combine_profile_stats(self._executor.phase_profile_stats,
362-
profile_filename)
362+
profile_filename) # pyrefly: ignore[bad-argument-type]
363363
for output_cb in self._test_options.output_callbacks:
364364
try:
365365
output_cb(final_state.test_record)
@@ -375,9 +375,9 @@ def trigger_phase(test):
375375
console_output.error_print(detail.description)
376376
else:
377377
colors = collections.defaultdict(lambda: colorama.Style.BRIGHT)
378-
colors[htf_test_record.Outcome.PASS] = ''.join(
378+
colors[htf_test_record.Outcome.PASS] = ''.join( # pyrefly: ignore[no-matching-overload]
379379
(colorama.Style.BRIGHT, colorama.Fore.GREEN)) # pytype: disable=wrong-arg-types
380-
colors[htf_test_record.Outcome.FAIL] = ''.join(
380+
colors[htf_test_record.Outcome.FAIL] = ''.join( # pyrefly: ignore[no-matching-overload]
381381
(colorama.Style.BRIGHT, colorama.Fore.RED)) # pytype: disable=wrong-arg-types
382382
msg_template = (
383383
'test: {name} outcome: {color}{outcome}{marginal}{rst}')
@@ -387,7 +387,7 @@ def trigger_phase(test):
387387
color=(colorama.Fore.YELLOW
388388
if final_state.test_record.marginal else
389389
colors[final_state.test_record.outcome]),
390-
outcome=final_state.test_record.outcome.name,
390+
outcome=final_state.test_record.outcome.name, # pyrefly: ignore[missing-attribute]
391391
marginal=(' (MARGINAL)'
392392
if final_state.test_record.marginal else ''),
393393
rst=colorama.Style.RESET_ALL))
@@ -503,7 +503,7 @@ class TestApi(object):
503503

504504
@property
505505
def dut_id(self) -> Text:
506-
return self.test_record.dut_id
506+
return self.test_record.dut_id # pyrefly: ignore[bad-return]
507507

508508
@dut_id.setter
509509
def dut_id(self, dut_id: Text) -> None:

openhtf/core/test_executor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def __init__(self, test_descriptor: 'test_descriptor.TestDescriptor',
107107
self._phase_exec = None # type: Optional[phase_executor.PhaseExecutor]
108108
self.uid = execution_uid
109109
self._last_outcome = None # type: Optional[phase_executor.PhaseExecutionOutcome]
110-
self._last_execution_unit: str = None
110+
self._last_execution_unit: str = None # pyrefly: ignore[bad-assignment]
111111
self._abort = threading.Event()
112112
self._full_abort = threading.Event()
113113
self._execution_finished = threading.Event()
@@ -248,7 +248,7 @@ def _initialize_plugs(
248248
"""
249249
try:
250250
self.running_test_state.plug_manager.initialize_plugs(
251-
plug_types=plug_types
251+
plug_types=plug_types # pyrefly: ignore[bad-argument-type]
252252
)
253253
return False
254254
except Exception: # pylint: disable=broad-except
@@ -277,7 +277,7 @@ def _execute_test_start(self) -> bool:
277277
# Have the phase executor run the start trigger phase. Do partial plug
278278
# initialization for just the plugs needed by the start trigger phase.
279279
if self._initialize_plugs(
280-
plug_types=[phase_plug.cls for phase_plug in self._test_start.plugs]):
280+
plug_types=[phase_plug.cls for phase_plug in self._test_start.plugs]): # pyrefly: ignore[bad-argument-type]
281281
return True
282282

283283
outcome, profile_stats = self.phase_executor.execute_phase(
@@ -493,7 +493,7 @@ def _subtest_context(
493493
outcome=test_record.SubtestOutcome.PASS)
494494
yield subtest_rec
495495
subtest_rec.end_time_millis = util.time_millis()
496-
self.test_state.test_record.add_subtest_record(subtest_rec)
496+
self.test_state.test_record.add_subtest_record(subtest_rec) # pyrefly: ignore[missing-attribute]
497497

498498
def _execute_subtest(self, subtest: phase_collections.Subtest,
499499
outer_subtest_rec: Optional[test_record.SubtestRecord],

openhtf/core/test_record.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def close(self):
106106
if not self._filename:
107107
return
108108
os.remove(self._filename)
109-
self._filename = None
109+
self._filename = None # pyrefly: ignore[bad-assignment]
110110

111111
def _asdict(self) -> Dict[Text, Any]:
112112
# Don't include the attachment data when converting to dict.

0 commit comments

Comments
 (0)