Skip to content

Probably remove if __name__ == "__main__" #142

@shenxianpeng

Description

@shenxianpeng

Its weird that this worked!

Since we're omitting the entire file, we can probably remove

# ignore any branch that makes the module executable
'if __name__ == "__main__"',
because that only affected cpp_linter/__init__.py.

I don't see this used anywhere else in the source. On the other hand, it might be handy to use for quick tests in developing new features.

For example

# in new_module.py

def new_feature(arg: int) -> bool | None:
    if arg:
        return arg > 0
    return None

if __name__ == "__main__":
    assert new_feature(-1) is False
    assert new_feature(1) is True
    assert new_feature(0) is None

And then just run python -m cpp_linter.new_module.

Originally posted by @2bndy5 in #140 (comment)

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