Skip to content

Commit

Permalink
Fixed issues raised by new Pylint version 2.9
Browse files Browse the repository at this point in the history
Details:

* Fixed new issue deprecated-class when importing from collections as a fallback
  on Python versions that do not yet have collections.abc.

* Fixed consider-using-with on an open/close sequence in test code by using with.

* Circumvented a pylint issue where it raises no-member on Python 3.9 when
  accessing argparse parsing result members. (see issue #1001)

Signed-off-by: Andreas Maier <andreas.r.maier@gmx.de>
  • Loading branch information
andy-maier committed Jul 4, 2021
1 parent 6cd0a80 commit 7f9465d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions docs/changes.rst
Expand Up @@ -35,6 +35,8 @@ Released: not yet
The function display_cim_objects(...) uses valuemapping_for_property() but
specifies the default namespace as the target. (See issue #995)

* Fixed issues raised by new Pylint version 2.9.

**Enhancements:**

**Cleanup:**
Expand Down
1 change: 1 addition & 0 deletions pywbemtools/pywbemcli/_common.py
Expand Up @@ -25,6 +25,7 @@
try:
from collections.abc import Sequence
except ImportError:
# pylint: disable=deprecated-class
from collections import Sequence

import six
Expand Down
5 changes: 5 additions & 0 deletions pywbemtools/pywbemlistener/_cmd_listener.py
Expand Up @@ -425,6 +425,9 @@ def get_listeners(name=None):
args = parse_listener_args(listener_args)
if args:
if name is None or args.name == name:
# pylint: disable=no-member
# Note: This is a workaround for Pylint raising no-member on
# Python 3.9 (see issue #1001)
logfile = get_logfile(args.logdir, args.name)
lis = ListenerProperties(
name=args.name, port=args.port, scheme=args.scheme,
Expand All @@ -433,6 +436,8 @@ def get_listeners(name=None):
indi_file=args.indi_file, indi_format=args.indi_format,
logfile=logfile,
pid=p.pid, created=datetime.fromtimestamp(p.create_time()))
# pylint: enable=no-member
# Note: End of workaround
ret.append(lis)
return ret

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/pywbemcli/test_pywbem_server.py
Expand Up @@ -549,7 +549,8 @@ def test_pysvr_connect_attrs(testcase, init_kwargs, exp_attrs):

# Create temp fake file.
# NOTE: We cannot use fixtures because we are using simplified_test_function
open(FAKE_PEM_PATH, 'a').close()
with open(FAKE_PEM_PATH, 'a'):
pass

# connect and test connection results. Try block insures finally is
# called.
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/utils.py
Expand Up @@ -24,6 +24,7 @@
try:
from collections.abc import Mapping, Sequence
except ImportError:
# pylint: disable=deprecated-class
from collections import Mapping, Sequence
try:
from StringIO import StringIO # Python 2
Expand Down Expand Up @@ -249,8 +250,7 @@ def execute_command(cmdname, args, env=None, stdin=None, verbose=False,
rc = proc.returncode

# Restore environment of current process
for name in saved_env:
value = saved_env[name]
for name, value in saved_env.items():
if value is None:
del os.environ[name]
else:
Expand Down

0 comments on commit 7f9465d

Please sign in to comment.