Skip to content

Evaluation

FileTypeHintsCollector

Collects the type hints of multiple .py files.

__init__()

Creates an instance of FileTypeHintsCollector.

collect_data_from_file(root, filename)

Collects the typehint data from a file.

Parameters:

Name Type Description Default
root pathlib.Path

The root folder path of the file.

required
filename str

The file name.

required

collect_data_from_files(root, filenames)

Collects the typehint data from multiple files.

Parameters:

Name Type Description Default
root pathlib.Path

The root folder path of the files.

required
filenames list[str]

The file names.

required

collect_data_from_folder(root, folder, include_also_files_in_subdirectories=True)

Collects the typehint data from the files in the folder.

Parameters:

Name Type Description Default
root pathlib.Path

The root folder path.

required
folder pathlib.Path

The path of the folder containing the files.

required
include_also_files_in_subdirectories bool

Whether the type hints in the files in the subfolders should also be collected.

True

collect_data(root, file_paths)

Collects the typehint data from the files in the provided file paths.

Parameters:

Name Type Description Default
root pathlib.Path

The root folder path.

required
file_paths Iterable[pathlib.Path]

The file paths.

required

MetricDataCalculator

Calculates the metric data.

__init__()

Creates an instance of MetricDataCalculator.

add_filename_mapping(original_filename, generated_filename)

Adds a mapping: generated file name -> original file name. Used to determine which generated file corresponds to which original file. calculate the metric data.

Parameters:

Name Type Description Default
original_filename str

The original file name.

required
generated_filename str

The generated file name.

required

get_metric_data(original_type_hint_data, generated_type_hint_data)

Calculates the metric data containing the correctness & completeness.

Parameters:

Name Type Description Default
original_type_hint_data pd.DataFrame

The original typehint data.

required
generated_type_hint_data pd.DataFrame

The generated typehint data.

required

get_total_completeness_and_correctness(metric_data)

Gets the total completeness & correctness of a given metric data.

Parameters:

Name Type Description Default
metric_data pd.DataFrame

The metric data.

required

Returns:

Type Description
tuple[float, float]

The total completeness & correctness.

normalize_type(type_hint)

Gets the type union written as a type union using only | . Normalizes typing.Union, typing.Optional and | unions. Does also normalize inner type unions, for example: list[int | str].

Parameters:

Name Type Description Default
type_hint str

The type hint name to normalize.

required

Returns:

Type Description
str

the normalized type hint name.

PerformanceDataFileCollector

Bases: DataFileCollector

Collects performance data files in a given path.

__init__()

Creates an instance of PerformanceDataFileCollector.

collect_data(path, include_also_files_in_subdirectories=False)

Collects the data in a given path.

Parameters:

Name Type Description Default
path pathlib.Path

The path of the folder containing the files.

required
include_also_files_in_subdirectories bool

Whether the data files in the subfolders should also be collected.

False