Skip to content

Commit 5bb072d

Browse files
dguidoclaude
andcommitted
Fix ruff formatting for PR
- Format analysis.py and test_bypasses.py with ruff - Remove mypy from pre-commit hooks (was already skipped in CI) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent a0054df commit 5bb072d

File tree

2 files changed

+54
-14
lines changed

2 files changed

+54
-14
lines changed

fickling/analysis.py

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,59 @@ class UnsafeImportsML(Analysis):
249249

250250
# Builtins that are safe to import - pure functions and type constructors
251251
# that cannot be used for code execution or system access
252-
SAFE_BUILTINS = frozenset([
253-
# Type constructors (create data, cannot execute code)
254-
"bool", "int", "float", "complex", "str", "bytes", "bytearray",
255-
"list", "tuple", "set", "frozenset", "dict",
256-
# Pure functions (no side effects, no code execution)
257-
"len", "abs", "sum", "min", "max", "round", "pow", "divmod",
258-
"sorted", "reversed", "enumerate", "zip", "range",
259-
"map", "filter", "slice", "iter", "next",
260-
"all", "any", "hash", "id", "repr", "ascii", "bin", "hex", "oct", "ord", "chr",
261-
"isinstance", "issubclass", "type", "object",
262-
"callable", "format",
263-
])
252+
SAFE_BUILTINS = frozenset(
253+
[
254+
# Type constructors (create data, cannot execute code)
255+
"bool",
256+
"int",
257+
"float",
258+
"complex",
259+
"str",
260+
"bytes",
261+
"bytearray",
262+
"list",
263+
"tuple",
264+
"set",
265+
"frozenset",
266+
"dict",
267+
# Pure functions (no side effects, no code execution)
268+
"len",
269+
"abs",
270+
"sum",
271+
"min",
272+
"max",
273+
"round",
274+
"pow",
275+
"divmod",
276+
"sorted",
277+
"reversed",
278+
"enumerate",
279+
"zip",
280+
"range",
281+
"map",
282+
"filter",
283+
"slice",
284+
"iter",
285+
"next",
286+
"all",
287+
"any",
288+
"hash",
289+
"id",
290+
"repr",
291+
"ascii",
292+
"bin",
293+
"hex",
294+
"oct",
295+
"ord",
296+
"chr",
297+
"isinstance",
298+
"issubclass",
299+
"type",
300+
"object",
301+
"callable",
302+
"format",
303+
]
304+
)
264305

265306
# Builtins that are DANGEROUS and must remain blocked
266307
# (for documentation - these are NOT in SAFE_BUILTINS)

test/test_bypasses.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,7 @@ def test_unsafe_builtins_still_flagged(self):
426426
# Should be flagged by at least one of the unsafe import checkers
427427
detailed = res.detailed_results().get("AnalysisResult", {})
428428
has_unsafe_import = (
429-
detailed.get("UnsafeImports") is not None
430-
or detailed.get("UnsafeImportsML") is not None
429+
detailed.get("UnsafeImports") is not None or detailed.get("UnsafeImportsML") is not None
431430
)
432431
self.assertTrue(has_unsafe_import)
433432

0 commit comments

Comments
 (0)