Skip to content

removing "r" in open(..., "r") is not an upgrade #714

@nmichlo

Description

@nmichlo

While open("foo", "r") may be considered redundant, some may arguably consider it explicit instead, since It is not always immediately obvious that open("foo") defaults to read only without first consulting the python documentation.

I do, however, agree that the following is an appropriate change for pyupgrade, since the U flag is explicitly deprecated.

-open("foo", "rUb")
+open("foo", "rb")

The "r" flag on the other hand is not deprecated, rather when used it is often for readability purposes, and so removing it is a stylistic choice, not necessarily an upgrade.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions