Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update linters and adapt code for compatibility (SC-986) #1434

Merged
merged 4 commits into from
May 5, 2022
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
3 changes: 2 additions & 1 deletion cloudinit/cmd/devel/hotplug_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def handle_hotplug(hotplug_init: Init, devpath, subsystem, udevaction):
success_fn=hotplug_init._write_to_cache,
) # type: UeventHandler
wait_times = [1, 3, 5, 10, 30]
last_exception = Exception("Bug while processing hotplug event.")
Copy link
Member

Choose a reason for hiding this comment

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

We already have a #type: ignore in the else clause for this particular issue. Lets either remove that hint with this change, or remove this change and add another linting hint.

for attempt, wait in enumerate(wait_times):
LOG.debug(
"subsystem=%s update attempt %s/%s",
Expand All @@ -231,7 +232,7 @@ def handle_hotplug(hotplug_init: Init, devpath, subsystem, udevaction):
time.sleep(wait)
last_exception = e
else:
raise last_exception # type: ignore
raise last_exception


def handle_args(name, args):
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
from setuptools.command.egg_info import egg_info
from setuptools.command.install import install

# pylint: disable=W0402
try:
from setuptools.errors import DistutilsError
except ImportError:
from distutils.errors import DistutilsArgError as DistutilsError
# pylint: enable=W0402

RENDERED_TMPD_PREFIX = "RENDERED_TEMPD"
VARIANT = None
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/config/test_cc_growpart.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ def mystat(path):
raise e
return real_stat(path)

opinfo = cc_growpart.device_part_info
try:
opinfo = cc_growpart.device_part_info
cc_growpart.device_part_info = simple_device_part_info
os.stat = mystat

Expand Down
5 changes: 2 additions & 3 deletions tests/unittests/sources/test_configdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,11 +603,10 @@ def my_devs_with(*args, **kwargs):
def my_is_partition(dev):
return dev[-1] in "0123456789" and not dev.startswith("sr")

orig_find_devs_with = util.find_devs_with
orig_is_partition = util.is_partition
try:
orig_find_devs_with = util.find_devs_with
util.find_devs_with = my_devs_with

orig_is_partition = util.is_partition
util.is_partition = my_is_partition

devs_with_answers = {
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/test_ds_identify.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def call(
def write_mock(data):
ddata = {"out": None, "err": None, "ret": 0, "RET": None}
ddata.update(data)
for k in ddata:
for k in ddata.keys():
if ddata[k] is None:
ddata[k] = unset
return SHELL_MOCK_TMPL % ddata
Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ passenv=

[format_deps]
black==22.3.0
flake8==3.9.2
flake8==4.0.1
isort==5.10.1
mypy==0.931
pylint==2.11.1
pytest==7.0.0
mypy==0.950
pylint==2.13.8
pytest==7.0.1
types-jsonschema==4.4.2
types-oauthlib==3.1.6
types-PyYAML==6.0.4
Expand Down