Skip to content

[Refactor] PythonTA Multiple Function Arguments Readabililty Suggestion #1355

Description

@CulmoneY

Description

In general, for function calls with many arguments, programmers should add parameter names to make it clear what each argument refers to.

For novice programmers, however, the benefits of this readability technique are not always obvious. Through code reviews, David has often encouraged this practice, but there is also a programmatic way to enforce it.

David himself has left similar comments on my PRs

Using the bare packing operator, a syntax barrier can be used to enforce keyword-only arguments:

def check_errors(
    module_name: Union[list[str], str] = "",
    config: Union[dict[str, Any], str] = "",
    output: Optional[Union[str, IO]] = None,
    load_default_config: bool = True,
    autoformat: Optional[bool] = False,
    on_verify_fail: Literal["log", "raise"] = "log",
) -> PythonTaReporter:

can become

def check_errors(
    *,
    module_name: Union[list[str], str] = "",
    config: Union[dict[str, Any], str] = "",
    output: Optional[Union[str, IO]] = None,
    load_default_config: bool = True,
    autoformat: Optional[bool] = False,
    on_verify_fail: Literal["log", "raise"] = "log",
) -> PythonTaReporter:

This would help avoid comments like the ones I received.

If this readability technique is found useful, a PythonTA custom linter could be added to enforce the rule.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions