diff --git a/.pylintrc b/.pylintrc index 5b5816c0..f2734d90 100644 --- a/.pylintrc +++ b/.pylintrc @@ -46,7 +46,7 @@ load-plugins= # W0141 - Use of builtin functions # -# For now, priorize Python3 mirgration as the use of pylint (e.g. enconding warnings). +# Disable warnings that are not severe, but warn e.g about missing encoding: # disable=W0142,W0703,C0111,R0201,W0603,W0613,W0212,W0141, bad-option-value, # Skip complaining about suppressions for older option values diff --git a/README.md b/README.md index bb876c03..b58744d3 100644 --- a/README.md +++ b/README.md @@ -176,7 +176,7 @@ See for the context of this e ## Guidelines -Charset encoding/string handling: +Character set encoding/string handling: See [README-Unicode.md](README-Unicode.md) for details on Unicode support. ## Users diff --git a/pylint_runner.py b/pylint_runner.py index b013f66f..ff935393 100755 --- a/pylint_runner.py +++ b/pylint_runner.py @@ -6,21 +6,15 @@ - Markdown Reports for showing them in the GitHub Actions Summary - a pylint.txt for diff-quality to ensure no regressions in diffs. -Pylint for Python2 does not support JSONReporter, so this wrapper only supports -the native Python3 checks, not the 2to3 conversion checks selected by the --py3k -options provied only in the Pylint for Python2. -The older pylint-2.16 could be checked if it supports both. - -The output for GitHub of this script is fitered for putting the -focus on severen warnings for the Python3 transition, expecially -the encoding warnings are important. +The output for GitHub of this script is filtered for focussing on severe warnings. +Especially, the encoding warnings are important. On stdout, the format used by GitHub to generate error annotations us used. These error annotations are shown on the top of the GitHub Action summary page and are also shown in the diff view at the their code locations. It also generates a markdown report including two Markdown -tables (one for summary, one with the individual erros) +tables (one for summary, one with the individual errors) which can be viewed locally and is also shown in the GitHub Action's Summary Report. """ @@ -99,7 +93,7 @@ def cleanup_results_dict(r, sym): # This is illegal according to: # https://docs.python.org/3/reference/datamodel.html#object.__hash__ # -# Reference: pylint3 removed the --py3k checker "because the transition is bedind us": +# Reference: pylint3 removed the --py3k checker "because the transition is behind us": # https://github.com/pylint-dev/pylint/blob/main/pylint/extensions/eq_without_hash.py # # But some checks are still useful in python3 after all, and this is the remnant of it. @@ -147,7 +141,6 @@ def pylint_project(check_dirs: List[str], errorlog: TextIO, branch_url: str): lineno = r["line"] # Write errors in the format for diff-quality to check against regressions: errorlog.write(f"{path}:{lineno}: [{msg_id}({sym}), {r['obj']}] {msg}\n") - # For suggestions to fix existing warnings, be more focussed on serverity: if not msg: continue @@ -214,7 +207,7 @@ def main(dirs: List[str], output_file: str, pylint_logfile: str, branch_url: str with open(pylint_logfile, "w", encoding="utf-8") as txt_out: panda_overview, panda_results = pylint_project(dirs, txt_out, branch_url) - # Write the panda dable to a markdown output file: + # Write the panda table to a markdown output file: summary_file = output_file or os.environ.get("GITHUB_STEP_SUMMARY") if not summary_file: return diff --git a/pytype_runner.py b/pytype_runner.py index 9625736f..76ed0357 100755 --- a/pytype_runner.py +++ b/pytype_runner.py @@ -163,7 +163,7 @@ def setup_and_run_pytype_action(scriptname: str): branch = os.environ.get("GITHUB_HEAD_REF", None) or os.environ.get("GITHUB_REF_NAME", None) filelink_baseurl = f"{server_url}/{repository}/blob/{branch}" retcode, results = run_pytype_and_parse_annotations(xfail_files, filelink_baseurl) - # Write the panda dable to a markdown output file: + # Write the panda table to a markdown output file: summary_file = os.environ.get("GITHUB_STEP_SUMMARY", None) if summary_file: with open(summary_file, "w", encoding="utf-8") as fp: diff --git a/tests/conftest.py b/tests/conftest.py index da395853..a0ff0d1d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -24,14 +24,12 @@ def set_warnings(): One purpose of this fixture that with it, we can globally enable Development Mode (https://docs.python.org/3/library/devmode.html) - using setenv = PYTHONDEVMODE=yes in tox.int which enables further + using setenv:PYTHONDEVMODE=yes in tox.ini which enables further run-time checking during tests. - By additionally using setenv = PYTHONWARNINGS=ignore in tox.ini, - we can disabling the Deprecation warnings wihch pytest plugins exhibit - (which we are not interested in, those are not our responsiblity). - and this fixture will still enable the default warning filter to - have e.g. ResourceWarning checks enabled. + Using setenv:PYTHONWARNINGS=ignore in tox.ini, we disable the Deprecation + warnings caused by pytest plugins. This fixture still enable the default + warning filter to have e.g. ResourceWarning checks enabled. Another nice effect is that also during interactive pytest use, the default warning filter also provides checking of ResourceWarning: diff --git a/tests/test_bootloader.py b/tests/test_bootloader.py index 23b21a5e..6c31d00a 100644 --- a/tests/test_bootloader.py +++ b/tests/test_bootloader.py @@ -48,7 +48,7 @@ def test_grub2(self): class TestLinuxBootloader(unittest.TestCase): def setUp(self): - self.tmpdir = mkdtemp(prefix="testbl") + self.tmpdir = mkdtemp(prefix="test-bootloader") bootdir = os.path.join(self.tmpdir, "boot") grubdir = os.path.join(bootdir, "grub") os.makedirs(grubdir) diff --git a/tests/test_ifrename_logic.py b/tests/test_ifrename_logic.py index f6966054..29221e2d 100644 --- a/tests/test_ifrename_logic.py +++ b/tests/test_ifrename_logic.py @@ -77,7 +77,7 @@ def test_newhw_norules_1eth(self): def test_newhw_norules_2eth(self): """ Two previously unrecognised nics, with no other rules. Expecting - them to be renamed to eth0 and 1 respectivly + them to be renamed to eth0 and 1 respectively """ eth0 = MACPCI("ab:cd:ef:12:34:56","0000:00:0f.0","side-12-eth1") @@ -96,7 +96,7 @@ def test_newhw_norules_2eth(self): def test_newhw_1srule_1eth(self): """ - One previously unrecognised nic with a static rule refering to it. + One previously unrecognised nic with a static rule referring to it. Expecting it to be named to eth0 as per the static rule. """ @@ -336,7 +336,7 @@ def test_usecase5(self): def test_CA_94279(self): """ - CA-94279 occured because the logic did no honour the order paramater + CA-94279 occurred because the logic did no honor the order parameter from biosdevname if it was the only deciding factor. (It appears rare for the embedded network cards to have a greater PCI sbdf than the non- embedded cards) @@ -528,11 +528,11 @@ def setUp(self): Set up a lot of MACPCI objects. This reflection magic creates many self.cXXX objects where XXX - represents the indicies of mac, pci and eth names. + represents the indices of mac, pci and eth names. e.g. self.c123 means the 1st mac, 2nd pci and 3rd eth self.c221 means the 2nd mac, 2nd pci and 1st eth - In addition, set up equivelent self.sXXX objects which have a kname + In addition, set up equivalent self.sXXX objects which have a kname set to None and a tname set to the 'eth' """ diff --git a/tests/test_mac.py b/tests/test_mac.py index 7976a3bf..f76f25ed 100644 --- a/tests/test_mac.py +++ b/tests/test_mac.py @@ -45,7 +45,7 @@ def test_colon_too_many_octets(self): MAC(val) self.assertFalse(MAC.is_valid(val)) - def test_dash_too_few_octetes(self): + def test_dash_too_few_octets(self): val = "00-00-00-00-00" with self.assertRaises(ValueError): MAC(val) @@ -190,7 +190,7 @@ def test_random(self): self.assertEqual(mac.as_string("-", True), "15-52-4A-B4-0C-FF") self.assertEqual(mac.as_string(".", True), "1552.4AB4.0CFF") -class TestCompaisons(unittest.TestCase): +class TestComparisons(unittest.TestCase): def test_equal(self): diff --git a/tests/test_sbdfi_to_nic.py b/tests/test_sbdfi_to_nic.py index 5bb9a5af..018a02bf 100644 --- a/tests/test_sbdfi_to_nic.py +++ b/tests/test_sbdfi_to_nic.py @@ -35,7 +35,7 @@ def check_raises(exc_type, func, sbdfi, nic_list): def test_sbdf_index(): - """Test all possible uses and xcp.pci.pci_sbdfi_to_nic() and raised Execptions""" + """Test all possible uses and xcp.pci.pci_sbdfi_to_nic() and raised Exceptions""" assert pci_sbdfi_to_nic("0000:01:00.0", nics) == nics[0] assert pci_sbdfi_to_nic("0000:01:00.0[0]", nics) == nics[0] assert pci_sbdfi_to_nic("0000:01:00.0[1]", nics) == nics[1] diff --git a/xcp/accessor.py b/xcp/accessor.py index afdb643d..7da5076a 100644 --- a/xcp/accessor.py +++ b/xcp/accessor.py @@ -395,11 +395,11 @@ def __repr__(self): return "" % self.baseAddress -# Tuple passed in tests to isinstanc(val, ...Types) to check types: +# Tuple passed in tests to isinstance(val, ...Types) to check types: MountingAccessorTypes = (DeviceAccessor, NFSAccessor) """Tuple for type checking in unit tests testing subclasses of MountingAccessor""" -# Tuple passed in tests to isinstanc(val, ...Types) to check types: +# Tuple passed in tests to isinstance(val, ...Types) to check types: LocalTypes = (DeviceAccessor, NFSAccessor, FileAccessor) diff --git a/xcp/compat.py b/xcp/compat.py index 9a08772e..bdb2bec6 100644 --- a/xcp/compat.py +++ b/xcp/compat.py @@ -38,7 +38,7 @@ def open_with_codec_handling(filename, mode="r", encoding="utf-8", **kwargs): def open_with_codec_handling(filename, mode="r", encoding="", errors="", **kwargs): # type:(str, str, str, str, str) -> IO[Any] - """open() wrapper to pass mode and **kwargs to open(), ignores endcoding and errors args""" + """open() wrapper to pass mode and **kwargs to open(), ignores encoding and errors args""" _ = encoding _ = errors return open(filename, mode, **kwargs) diff --git a/xcp/net/biosdevname.py b/xcp/net/biosdevname.py index 9c1427c4..a2bb548b 100644 --- a/xcp/net/biosdevname.py +++ b/xcp/net/biosdevname.py @@ -51,7 +51,7 @@ def all_devices_all_names(): Get all information, including all names, for all devices. Returns a dictionary of devices, indexed by current kernel name. All entries will be string to string mappings, with the exception of - 'BIOS device' which will be a dictonary of policies to names. + 'BIOS device' which will be a dictionary of policies to names. """ devices = {} @@ -90,7 +90,7 @@ def all_devices_all_names(): def has_ppn_quirks(bdn_dicts): # CA-75599 - Assert that no devices share the same SMBIOS Instance. Some - # BIOSes have multiple different nics with the same value set, which causes + # BIOSes have multiple different NICs with the same value set, which causes # biosdevname to mis-name its physical policy names (emXX, pciXpX etc) smbios_instances = set() diff --git a/xcp/net/ifrename/logic.py b/xcp/net/ifrename/logic.py index 476dc2d7..f294bfbe 100644 --- a/xcp/net/ifrename/logic.py +++ b/xcp/net/ifrename/logic.py @@ -33,7 +33,7 @@ list of MACPCI objects in form ethXXX|side-XXX-ethXX->(mac, pci) [in] last_state - Last boot state (post rename) of network cards on the machine list of MACPCI objects in form (mac, pci)->ethXX -[in] old_state - Any older nics which have disappeared in the meantime +[in] old_state - Any older NICs which have disappeared in the meantime list of MACPCI objects in form (mac, pci)->ethXX [out] transactions diff --git a/xcp/net/ifrename/static.py b/xcp/net/ifrename/static.py index 76ab3723..2c1092c9 100644 --- a/xcp/net/ifrename/static.py +++ b/xcp/net/ifrename/static.py @@ -184,7 +184,7 @@ def load_and_parse(self): # If no validators, assume label method = "label" - # If we have a validator, test the valididy + # If we have a validator, test the validity else: if method in StaticRules.validators: if StaticRules.validators[method].match(value) is None: @@ -215,7 +215,7 @@ def generate(self, state): """ # CA-75599 - check that state has no shared ppns. - # See net.biodevname.has_ppn_quirks() for full reason + # See net.biosdevname.has_ppn_quirks() for full reason ppns = [ x.ppn for x in state if x.ppn is not None ] ppn_quirks = ( len(ppns) != len(set(ppns)) ) @@ -311,7 +311,7 @@ def write(self, header = True): LOG.warning("Method %s not recognised. Ignoring" % (method,)) continue - # If we have a validator, test the valididy + # If we have a validator, test the validity if method in StaticRules.validators: if StaticRules.validators[method].match(value) is None: LOG.warning("Invalid %s value '%s'. Ignoring" diff --git a/xcp/net/ip.py b/xcp/net/ip.py index 55b7e832..e9b068c6 100644 --- a/xcp/net/ip.py +++ b/xcp/net/ip.py @@ -85,7 +85,7 @@ def ip_link_set_name(src_name, dst_name): # if the device was up before, bring it back up if isup: - # Performace note: if we are doing an intermediate rename to + # Performance note: if we are doing an intermediate rename to # move a device sideways, we shouldn't bring it back until it has # its final name. However, I can't think of a non-hacky way of doing # this with the current implementation diff --git a/xcp/net/mac.py b/xcp/net/mac.py index 0d72a93c..976ffc68 100644 --- a/xcp/net/mac.py +++ b/xcp/net/mac.py @@ -44,7 +44,7 @@ class MAC(object): @classmethod def is_valid(cls, addr): """ - Static method to assertain whether addr is a recognised MAC address or + Static method to ascertain whether addr is a recognised MAC address or not """ try: @@ -134,7 +134,7 @@ def as_string(self, sep = ".", upper = False): if sep == ".": # this is a hack but I cant think of an easy way of - # manipulating self.octetes + # manipulating self.octets res = "%0.4x.%0.4x.%0.4x" % ( (self.integer >> 32) & 0xffff, (self.integer >> 16) & 0xffff, (self.integer ) & 0xffff ) @@ -146,7 +146,7 @@ def as_string(self, sep = ".", upper = False): res = ':'.join([ "%0.2x" % o for o in self.octets]) else: - raise ValueError("'%s' is not a valid seperator" % sep) + raise ValueError("'%s' is not a valid separator" % sep) if upper: return res.upper() diff --git a/xcp/pci.py b/xcp/pci.py index ef5cec29..1e41e345 100644 --- a/xcp/pci.py +++ b/xcp/pci.py @@ -50,8 +50,7 @@ class PCI(object): @classmethod def is_valid(cls, addr): """ - Static method to assertain whether addr is a recognised PCI address - or not + Static method to ascertain whether addr is a recognised PCI address """ try: PCI(addr)