Skip to content

RUF064 should ignore or fix multi-digit decimal zeros #19010

@dscorbett

Description

@dscorbett

Summary

non-octal-permissions (RUF064) ignores a decimal zero except when it has multiple digits. People sometimes write zero as 000 to parallel other three-digit permissions. RUF064 should either ignore multi-digit decimal zeros or fix them to octal zeros. The fix could be safe.

Playground

$ cat >ruf064.py <<'# EOF'
import os
os.chmod("secrets.txt", 000)
# EOF

$ ruff --isolated check ruf064.py --select RUF064 --preview
ruf064.py:2:25: RUF064 Non-octal mode
  |
1 | import os
2 | os.chmod("secrets.txt", 000)
  |                         ^^^ RUF064
  |
  = help: Replace with octal literal

Found 1 error.

Version

ruff 0.12.1 (32c5418 2025-06-26)

Metadata

Metadata

Assignees

No one assigned

    Labels

    previewRelated to preview mode featuresruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions