Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 30 additions & 83 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ hashbrown = { version = "0.16.0", default-features = false, features = [
"inline-more",
] }
heck = "0.5.0"
icu_properties = { version = "2.1.2" }
ignore = { version = "0.4.24" }
imara-diff = { version = "0.2.0" }
imperative = { version = "1.0.4" }
Expand Down Expand Up @@ -199,7 +200,6 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
] }
tryfn = { version = "1.0.0" }
typed-arena = { version = "2.0.2" }
unic-ucd-category = { version = "0.9" }
unicode-ident = { version = "1.0.12" }
unicode-normalization = { version = "0.1.23" }
unicode-width = { version = "0.2.0" }
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_python_literal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ doctest = false
ruff_python_ast = { workspace = true }

bitflags = { workspace = true }
icu_properties = { workspace = true }
itertools = { workspace = true }
unic-ucd-category = { workspace = true }

[dev-dependencies]

Expand Down
17 changes: 14 additions & 3 deletions crates/ruff_python_literal/src/char.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use unic_ucd_category::GeneralCategory;
use icu_properties::props::{EnumeratedProperty, GeneralCategory};

/// According to python following categories aren't printable:
/// * Cc (Other, Control)
Expand All @@ -10,6 +10,17 @@ use unic_ucd_category::GeneralCategory;
/// * Zp Separator, Paragraph ('\u2029', PARAGRAPH SEPARATOR)
/// * Zs (Separator, Space) other than ASCII space('\x20').
pub fn is_printable(c: char) -> bool {
let cat = GeneralCategory::of(c);
!(cat.is_other() || cat.is_separator())
let cat = GeneralCategory::for_char(c);

!matches!(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Let's reorder them so that they match the doc-comment

cat,
GeneralCategory::Control
| GeneralCategory::Format
| GeneralCategory::Surrogate
| GeneralCategory::PrivateUse
| GeneralCategory::Unassigned
| GeneralCategory::LineSeparator
| GeneralCategory::ParagraphSeparator
| GeneralCategory::SpaceSeparator
)
}
Loading