Skip to content

Commit

Permalink
Fix use-dict-literal pylint rule
Browse files Browse the repository at this point in the history
And remove relevant disabled pylint rules from pylintrc.
  • Loading branch information
KKoukiou committed Dec 17, 2024
1 parent 8d656f8 commit 2a943fb
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 22 deletions.
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def read_version():
autoclass_content = 'both'

# Inheritence diagram graphviz settings
inheritance_graph_attrs = dict(rankdir="UD", fontsize=14, ratio='auto')
inheritance_node_attrs = dict(style='rounded', margin='"0.07, 0.07"')
inheritance_graph_attrs = {"rankdir": 'UD', "fontsize": 14, "ratio": 'auto'}
inheritance_node_attrs = {"style": 'rounded', "margin": '"0.07, 0.07"'}

# -- Options for HTML output ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion pyanaconda/argument_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(self, *args, **kwargs):
True: ignore the argument without the prefix. (default)
"""
help_width = get_help_width()
self._boot_arg = dict()
self._boot_arg = {}
self.bootarg_prefix = kwargs.pop("bootarg_prefix", "")
self.require_prefix = kwargs.pop("require_prefix", True)

Expand Down
2 changes: 1 addition & 1 deletion pyanaconda/core/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def _is_device_name_disk(device_name, devicetree=None, refresh_udev_cache=False)
# so we cache it in this non-elegant way.
# An unfortunate side effect of this is that udev devices that show up after
# this function is called for the first time will not be taken into account.
_udev_device_dict_cache = dict()
_udev_device_dict_cache = {}

for d in udev.get_devices():
# Add the device name to the cache.
Expand Down
2 changes: 1 addition & 1 deletion pyanaconda/core/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class AnacondaThread(threading.Thread):
"""

# class-wide dictionary ensuring unique thread names
_prefix_thread_counts = dict()
_prefix_thread_counts = {}

def __init__(self, *args, **kwargs):
# if neither name nor prefix is given, use the worker prefix
Expand Down
2 changes: 1 addition & 1 deletion pyanaconda/installation_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def __init__(self, task_name, task_cb, task_args=None, task_kwargs=None):
super().__init__(task_name)
self._task_cb = task_cb
self._task_args = task_args or []
self._task_kwargs = task_kwargs or dict()
self._task_kwargs = task_kwargs or {}

@property
def summary(self):
Expand Down
4 changes: 2 additions & 2 deletions pyanaconda/modules/storage/checker/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ class StorageChecker:

def __init__(self):
self.checks = []
self.constraints = dict()
self.constraints = {}

def add_check(self, callback):
""" Add a callback for storage checking.
Expand Down Expand Up @@ -701,7 +701,7 @@ def get_default_constraint_names(self):

def set_default_constraints(self):
"""Set the default constraints needed by default checks."""
self.constraints = dict()
self.constraints = {}

for name in self.get_default_constraint_names():
self.add_constraint(name, getattr(conf.storage_constraints, name))
Expand Down
2 changes: 1 addition & 1 deletion pyanaconda/ui/gui/spokes/lib/network_secret_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def GetSecrets(

content = self._get_content(setting_name, unpacked_connection_hash)

secrets = dict()
secrets = {}
if self._ui_callback(content):
for secret in content['secrets']:
if secret['key']:
Expand Down
4 changes: 2 additions & 2 deletions pyanaconda/ui/gui/xkl_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ def __init__(self):

self._rxkb = rxkb.Context()

self._layout_infos = dict()
self._layout_infos = {}
self._build_layout_infos()

self._switch_opt_infos = dict()
self._switch_opt_infos = {}
self._build_switch_opt_infos()

def _build_layout_infos(self):
Expand Down
2 changes: 1 addition & 1 deletion scripts/anaconda-cleanup
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pyanaconda.anaconda_logging.init(write_to_journal=False)
from blivet.devicetree import DeviceTree
from gi.repository import BlockDev as blockdev

disk_images = dict()
disk_images = {}

# find devices representing disk images
sys_class_block = "/sys/class/block"
Expand Down
1 change: 0 additions & 1 deletion tests/pylint/pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ disable=protected-access,
too-many-public-methods,
too-many-return-statements,
too-many-statements,
use-dict-literal,
useless-return,
# End R (refactoring) whitelist

Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/pyanaconda_tests/core/test_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_items_raw(self):
# Re-enable the following line when the issue is fixed
# assert isinstance(it, Iterable)

res = dict()
res = {}
for k, v in it:
res[k] = v

Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/pyanaconda_tests/core/test_live_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_get_live_user_with_failed_getpwuid(self, getpwuid_mock, conf_mock):

@patch("pyanaconda.core.live_user.conf")
@patch("pyanaconda.core.live_user.getpwuid")
@patch.dict("pyanaconda.core.live_user.os.environ", dict())
@patch.dict("pyanaconda.core.live_user.os.environ", {})
def test_get_live_user_with_missing_pkexec_env(self, getpwuid_mock, conf_mock):

conf_mock.system.provides_liveuser = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def test_default_settings(self):
'/home': Size("100 MiB"),
'/boot': Size("512 MiB")
},
checks.STORAGE_REQ_PARTITION_SIZES: dict(),
checks.STORAGE_REQ_PARTITION_SIZES: {},
checks.STORAGE_MUST_BE_ON_LINUXFS: {
'/', '/var', '/tmp', '/usr', '/home', '/usr/share', '/usr/lib'
},
Expand Down
10 changes: 5 additions & 5 deletions tests/unit_tests/pyanaconda_tests/test_localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def test_common_keyboard_layouts(self):
def test_locale_timezones(self):
assert "Europe/Oslo" in localization.get_locale_timezones("no")

@patch.dict("pyanaconda.localization.os.environ", dict())
@patch.dict("pyanaconda.localization.os.environ", {})
def test_xlated_tz(self):
localization.os.environ["LANG"] = "en_US"
assert "Europe/Barcelona" == localization.get_xlated_timezone("Europe/Barcelona")
Expand Down Expand Up @@ -127,7 +127,7 @@ def test_setup_locale_notext(self, set_modules_locale_mock, setlocale_mock, sete

assert locale == "sk"

@patch.dict("pyanaconda.localization.os.environ", dict())
@patch.dict("pyanaconda.localization.os.environ", {})
@patch("pyanaconda.localization.locale_supported_in_console", return_value=False)
@patch("pyanaconda.localization.setenv")
@patch("pyanaconda.localization.locale_mod.setlocale")
Expand Down Expand Up @@ -194,7 +194,7 @@ def test_setup_locale_environment_param_ok(self, locales_mock):

assert DEFAULT_LANG in localization.os.environ["LANG"]

@patch.dict("pyanaconda.localization.os.environ", dict())
@patch.dict("pyanaconda.localization.os.environ", {})
def test_setup_locale_environment_vars(self):
"""Test setup_locale_environment() with multiple environment variables"""
for varname in ("LANGUAGE", "LC_ALL", "LC_MESSAGES", "LANG"):
Expand All @@ -216,7 +216,7 @@ def test_setup_locale_environment_vars_invalid(self):
assert DEFAULT_LANG == localization.os.environ["LANG"]

@patch("pyanaconda.localization.open")
@patch.dict("pyanaconda.localization.os.environ", dict())
@patch.dict("pyanaconda.localization.os.environ", {})
def test_setup_locale_environment_fallback_efi_ok(self, open_mock):
"""Test setup_locale_environment() fallback to EFI vars"""
# success with valid data
Expand All @@ -230,7 +230,7 @@ def test_setup_locale_environment_fallback_efi_ok(self, open_mock):
assert "de" in localization.os.environ["LANG"]

@patch("pyanaconda.localization.open")
@patch.dict("pyanaconda.localization.os.environ", dict())
@patch.dict("pyanaconda.localization.os.environ", {})
def test_setup_locale_environment_fallback_efi_bad(self, open_mock):
"""Test setup_locale_environment() fallback to EFI vars with bad contents"""
# failure with invalid data - too short
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/pyanaconda_tests/ui/test_simple_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def _check_spokes_priority_uniqueness(self):
self._check_spokes_with_same_priority(post_spokes)

def _check_spokes_with_same_priority(self, spokes):
res = dict()
res = {}

for spoke in spokes:
priority = spoke.priority
Expand Down

0 comments on commit 2a943fb

Please sign in to comment.