Skip to content

Commit 3bebfc1

Browse files
committed
Explain more in fix safety section
1 parent 0d583d4 commit 3bebfc1

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

crates/ruff_linter/src/rules/ruff/rules/non_octal_permissions.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ use crate::{FixAvailability, Violation};
3333
///
3434
/// This rule's fix is marked as unsafe because it changes runtime behavior.
3535
///
36+
/// Consider these examples:
37+
///
38+
/// ```python
39+
/// os.chmod("foo", 400)
40+
/// os.chmod("bar", 256)
41+
/// ```
42+
///
43+
/// `400` corresponds to `0o620` (`u=rw,g=w,o=`). If the intention was `0o400`
44+
/// (`u=r,go=`), the fix can be accepted safely, fixing a permissions issue.
45+
///
46+
/// `256` corresponds to `0o400` (`u=r,go=`). It is unlikely that `0o256`
47+
/// (`u=w,g=rx,o=rw`) was the intention here and so the fix should not be
48+
/// accepted. It is recommended to change this case to `0o400` manually.
49+
///
3650
/// ## Fix availability
3751
///
3852
/// A fix is only available if the existing digits could make up a valid octal literal.

0 commit comments

Comments
 (0)