From 36ede4eb05c508b727e41a0f43cc3c88c7a94633 Mon Sep 17 00:00:00 2001 From: Wolfgang Müller Date: Fri, 15 Nov 2024 15:52:00 +0100 Subject: backend/lint: Do not shadow certain builtins This commit enables ruff's flake8-builtin linter that emits warnings when builtin functions are shadowed. This is useful for builtins like "dict", "list", or "str" which we use often. Given the nature of this program we historically rely a lot on the usage of "id", "hash", and "filter" as variable names which also shadow Python builtins. For now let's ignore those, we have not used any of them in our code and the impact to the codebase would be considerable. This might be revisited in the future. --- tests/scrapers/test_scraper_utils.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/scrapers/test_scraper_utils.py') diff --git a/tests/scrapers/test_scraper_utils.py b/tests/scrapers/test_scraper_utils.py index 4b02aad..30b9796 100644 --- a/tests/scrapers/test_scraper_utils.py +++ b/tests/scrapers/test_scraper_utils.py @@ -8,23 +8,23 @@ from hircine.scraper.utils import open_archive_file, parse_dict def test_parse_dict(): - dict = { + data = { "scalar": "foo", "list": ["bar", "baz"], "dict": {"nested_scalar": "qux", "nested_list": ["plugh", "xyzzy"]}, } - def id(type): - return lambda item: f"{type}_{item}" + def annotate(tag): + return lambda item: f"{tag}_{item}" parsers = { - "scalar": id("scalar"), - "list": id("list"), - "dict": {"nested_scalar": id("scalar"), "nested_list": id("list")}, - "missing": id("missing"), + "scalar": annotate("scalar"), + "list": annotate("list"), + "dict": {"nested_scalar": annotate("scalar"), "nested_list": annotate("list")}, + "missing": annotate("missing"), } - assert [f() for f in parse_dict(parsers, dict)] == [ + assert [f() for f in parse_dict(parsers, data)] == [ "scalar_foo", "list_bar", "list_baz", -- cgit v1.2.3-2-gb3c3