Skip to content

Warn on improperly formatted parameter definitions #677

@timhoffm

Description

@timhoffm

Parameter name and types are split by " : "

val : int

It's a common mistake to leave out the leading space, i.e.

val: int

This results in the whole string being interpreted as "name" and thus incorrect rendering such as:

Image

The relevant code is:

if " : " in header:
arg_name, arg_type = header.split(" : ", maxsplit=1)
else:
# NOTE: param line with single element should never have a
# a " :" before the description line, so this should probably
# warn.
header = header.removesuffix(" :")
if single_element_is_type:
arg_name, arg_type = "", header
else:
arg_name, arg_type = header, ""

Would it be desirable to warn in that case? E.g. the most simple check in the else branch could be:

if ": " in header:
    # warn

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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