mirror of
https://github.com/astral-sh/ruff
synced 2026-01-09 07:34:06 -05:00
[refurb] Guard hashlib imports and mark hashlib-digest-hex fix as safe (FURB181) (#14694)
## Summary - Check if `hashlib` and `crypt` imports have been seen for `FURB181` and `S324` - Mark the fix for `FURB181` as safe: I think it was accidentally marked as unsafe in the first place. The rule does not support user-defined classes as the "fix safety" section suggests. - Removed `hashlib._Hash`, as it's not part of the `hashlib` module. <!-- What's the purpose of the change? What does it do, and why? --> ## Test Plan Updated the test snapshots
This commit is contained in:
@@ -1411,6 +1411,8 @@ impl<'a> SemanticModel<'a> {
|
||||
"typing_extensions" => self.seen.insert(Modules::TYPING_EXTENSIONS),
|
||||
"attr" | "attrs" => self.seen.insert(Modules::ATTRS),
|
||||
"airflow" => self.seen.insert(Modules::AIRFLOW),
|
||||
"hashlib" => self.seen.insert(Modules::HASHLIB),
|
||||
"crypt" => self.seen.insert(Modules::CRYPT),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -2039,6 +2041,8 @@ bitflags! {
|
||||
const ATTRS = 1 << 25;
|
||||
const REGEX = 1 << 26;
|
||||
const AIRFLOW = 1 << 27;
|
||||
const HASHLIB = 1 << 28;
|
||||
const CRYPT = 1 << 29;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user