Skip to content

Commit ed7bb9a

Browse files
Fix typos in code comments, simplify them
Signed-off-by: Bernhard Kaindl <[email protected]>
1 parent 2802010 commit ed7bb9a

17 files changed

+35
-45
lines changed

.pylintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ load-plugins=
4646
# W0141 - Use of builtin functions
4747

4848
#
49-
# For now, priorize Python3 mirgration as the use of pylint (e.g. enconding warnings).
49+
# Disable warnings that are not severe, but warn e.g about missing encoding:
5050
#
5151
disable=W0142,W0703,C0111,R0201,W0603,W0613,W0212,W0141,
5252
bad-option-value, # Skip complaining about suppressions for older option values

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ See <https://github.com/xenserver/python-libs/pull/23> for the context of this e
176176

177177
## Guidelines
178178

179-
Charset encoding/string handling:
179+
Character set encoding/string handling:
180180
See [README-Unicode.md](README-Unicode.md) for details on Unicode support.
181181

182182
## Users

pylint_runner.py

+5-12
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,15 @@
66
- Markdown Reports for showing them in the GitHub Actions Summary
77
- a pylint.txt for diff-quality to ensure no regressions in diffs.
88
9-
Pylint for Python2 does not support JSONReporter, so this wrapper only supports
10-
the native Python3 checks, not the 2to3 conversion checks selected by the --py3k
11-
options provied only in the Pylint for Python2.
12-
The older pylint-2.16 could be checked if it supports both.
13-
14-
The output for GitHub of this script is fitered for putting the
15-
focus on severen warnings for the Python3 transition, expecially
16-
the encoding warnings are important.
9+
The output for GitHub of this script is filtered for focussing on severe warnings.
10+
Especially, the encoding warnings are important.
1711
1812
On stdout, the format used by GitHub to generate error annotations us used.
1913
These error annotations are shown on the top of the GitHub Action summary page
2014
and are also shown in the diff view at the their code locations.
2115
2216
It also generates a markdown report including two Markdown
23-
tables (one for summary, one with the individual erros)
17+
tables (one for summary, one with the individual errors)
2418
which can be viewed locally and is also shown in the GitHub
2519
Action's Summary Report.
2620
"""
@@ -99,7 +93,7 @@ def cleanup_results_dict(r, sym):
9993
# This is illegal according to:
10094
# https://docs.python.org/3/reference/datamodel.html#object.__hash__
10195
#
102-
# Reference: pylint3 removed the --py3k checker "because the transition is bedind us":
96+
# Reference: pylint3 removed the --py3k checker "because the transition is behind us":
10397
# https://github.com/pylint-dev/pylint/blob/main/pylint/extensions/eq_without_hash.py
10498
#
10599
# 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):
147141
lineno = r["line"]
148142
# Write errors in the format for diff-quality to check against regressions:
149143
errorlog.write(f"{path}:{lineno}: [{msg_id}({sym}), {r['obj']}] {msg}\n")
150-
# For suggestions to fix existing warnings, be more focussed on serverity:
151144
if not msg:
152145
continue
153146

@@ -214,7 +207,7 @@ def main(dirs: List[str], output_file: str, pylint_logfile: str, branch_url: str
214207
with open(pylint_logfile, "w", encoding="utf-8") as txt_out:
215208
panda_overview, panda_results = pylint_project(dirs, txt_out, branch_url)
216209

217-
# Write the panda dable to a markdown output file:
210+
# Write the panda table to a markdown output file:
218211
summary_file = output_file or os.environ.get("GITHUB_STEP_SUMMARY")
219212
if not summary_file:
220213
return

pytype_runner.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def setup_and_run_pytype_action(scriptname: str):
163163
branch = os.environ.get("GITHUB_HEAD_REF", None) or os.environ.get("GITHUB_REF_NAME", None)
164164
filelink_baseurl = f"{server_url}/{repository}/blob/{branch}"
165165
retcode, results = run_pytype_and_parse_annotations(xfail_files, filelink_baseurl)
166-
# Write the panda dable to a markdown output file:
166+
# Write the panda table to a markdown output file:
167167
summary_file = os.environ.get("GITHUB_STEP_SUMMARY", None)
168168
if summary_file:
169169
with open(summary_file, "w", encoding="utf-8") as fp:

tests/conftest.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ def set_warnings():
2424
2525
One purpose of this fixture that with it, we can globally enable
2626
Development Mode (https://docs.python.org/3/library/devmode.html)
27-
using setenv = PYTHONDEVMODE=yes in tox.int which enables further
27+
using setenv:PYTHONDEVMODE=yes in tox.ini which enables further
2828
run-time checking during tests.
2929
30-
By additionally using setenv = PYTHONWARNINGS=ignore in tox.ini,
31-
we can disabling the Deprecation warnings wihch pytest plugins exhibit
32-
(which we are not interested in, those are not our responsiblity).
33-
and this fixture will still enable the default warning filter to
34-
have e.g. ResourceWarning checks enabled.
30+
Using setenv:PYTHONWARNINGS=ignore in tox.ini, we disable the Deprecation
31+
warnings caused by pytest plugins. This fixture still enable the default
32+
warning filter to have e.g. ResourceWarning checks enabled.
3533
3634
Another nice effect is that also during interactive pytest use, the
3735
default warning filter also provides checking of ResourceWarning:

tests/test_bootloader.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_grub2(self):
4848

4949
class TestLinuxBootloader(unittest.TestCase):
5050
def setUp(self):
51-
self.tmpdir = mkdtemp(prefix="testbl")
51+
self.tmpdir = mkdtemp(prefix="test-bootloader")
5252
bootdir = os.path.join(self.tmpdir, "boot")
5353
grubdir = os.path.join(bootdir, "grub")
5454
os.makedirs(grubdir)

tests/test_ifrename_logic.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def test_newhw_norules_1eth(self):
7777
def test_newhw_norules_2eth(self):
7878
"""
7979
Two previously unrecognised nics, with no other rules. Expecting
80-
them to be renamed to eth0 and 1 respectivly
80+
them to be renamed to eth0 and 1 respectively
8181
"""
8282

8383
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):
9696

9797
def test_newhw_1srule_1eth(self):
9898
"""
99-
One previously unrecognised nic with a static rule refering to it.
99+
One previously unrecognised nic with a static rule referring to it.
100100
Expecting it to be named to eth0 as per the static rule.
101101
"""
102102

@@ -336,7 +336,7 @@ def test_usecase5(self):
336336

337337
def test_CA_94279(self):
338338
"""
339-
CA-94279 occured because the logic did no honour the order paramater
339+
CA-94279 occurred because the logic did no honor the order parameter
340340
from biosdevname if it was the only deciding factor. (It appears rare
341341
for the embedded network cards to have a greater PCI sbdf than the non-
342342
embedded cards)
@@ -528,11 +528,11 @@ def setUp(self):
528528
Set up a lot of MACPCI objects.
529529
530530
This reflection magic creates many self.cXXX objects where XXX
531-
represents the indicies of mac, pci and eth names.
531+
represents the indices of mac, pci and eth names.
532532
e.g. self.c123 means the 1st mac, 2nd pci and 3rd eth
533533
self.c221 means the 2nd mac, 2nd pci and 1st eth
534534
535-
In addition, set up equivelent self.sXXX objects which have a kname
535+
In addition, set up equivalent self.sXXX objects which have a kname
536536
set to None and a tname set to the 'eth'
537537
"""
538538

tests/test_mac.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_colon_too_many_octets(self):
4545
MAC(val)
4646
self.assertFalse(MAC.is_valid(val))
4747

48-
def test_dash_too_few_octetes(self):
48+
def test_dash_too_few_octets(self):
4949
val = "00-00-00-00-00"
5050
with self.assertRaises(ValueError):
5151
MAC(val)
@@ -190,7 +190,7 @@ def test_random(self):
190190
self.assertEqual(mac.as_string("-", True), "15-52-4A-B4-0C-FF")
191191
self.assertEqual(mac.as_string(".", True), "1552.4AB4.0CFF")
192192

193-
class TestCompaisons(unittest.TestCase):
193+
class TestComparisons(unittest.TestCase):
194194

195195
def test_equal(self):
196196

tests/test_sbdfi_to_nic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def check_raises(exc_type, func, sbdfi, nic_list):
3535

3636

3737
def test_sbdf_index():
38-
"""Test all possible uses and xcp.pci.pci_sbdfi_to_nic() and raised Execptions"""
38+
"""Test all possible uses and xcp.pci.pci_sbdfi_to_nic() and raised Exceptions"""
3939
assert pci_sbdfi_to_nic("0000:01:00.0", nics) == nics[0]
4040
assert pci_sbdfi_to_nic("0000:01:00.0[0]", nics) == nics[0]
4141
assert pci_sbdfi_to_nic("0000:01:00.0[1]", nics) == nics[1]

xcp/accessor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,11 @@ def __repr__(self):
395395
return "<HTTPAccessor: %s>" % self.baseAddress
396396

397397

398-
# Tuple passed in tests to isinstanc(val, ...Types) to check types:
398+
# Tuple passed in tests to isinstance(val, ...Types) to check types:
399399
MountingAccessorTypes = (DeviceAccessor, NFSAccessor)
400400
"""Tuple for type checking in unit tests testing subclasses of MountingAccessor"""
401401

402-
# Tuple passed in tests to isinstanc(val, ...Types) to check types:
402+
# Tuple passed in tests to isinstance(val, ...Types) to check types:
403403
LocalTypes = (DeviceAccessor, NFSAccessor, FileAccessor)
404404

405405

xcp/compat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def open_with_codec_handling(filename, mode="r", encoding="utf-8", **kwargs):
3838

3939
def open_with_codec_handling(filename, mode="r", encoding="", errors="", **kwargs):
4040
# type:(str, str, str, str, str) -> IO[Any]
41-
"""open() wrapper to pass mode and **kwargs to open(), ignores endcoding and errors args"""
41+
"""open() wrapper to pass mode and **kwargs to open(), ignores encoding and errors args"""
4242
_ = encoding
4343
_ = errors
4444
return open(filename, mode, **kwargs)

xcp/net/biosdevname.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def all_devices_all_names():
5151
Get all information, including all names, for all devices.
5252
Returns a dictionary of devices, indexed by current kernel name. All
5353
entries will be string to string mappings, with the exception of
54-
'BIOS device' which will be a dictonary of policies to names.
54+
'BIOS device' which will be a dictionary of policies to names.
5555
"""
5656

5757
devices = {}
@@ -90,7 +90,7 @@ def all_devices_all_names():
9090

9191
def has_ppn_quirks(bdn_dicts):
9292
# CA-75599 - Assert that no devices share the same SMBIOS Instance. Some
93-
# BIOSes have multiple different nics with the same value set, which causes
93+
# BIOSes have multiple different NICs with the same value set, which causes
9494
# biosdevname to mis-name its physical policy names (emXX, pciXpX etc)
9595

9696
smbios_instances = set()

xcp/net/ifrename/logic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
list of MACPCI objects in form ethXXX|side-XXX-ethXX->(mac, pci)
3434
[in] last_state - Last boot state (post rename) of network cards on the machine
3535
list of MACPCI objects in form (mac, pci)->ethXX
36-
[in] old_state - Any older nics which have disappeared in the meantime
36+
[in] old_state - Any older NICs which have disappeared in the meantime
3737
list of MACPCI objects in form (mac, pci)->ethXX
3838
3939
[out] transactions

xcp/net/ifrename/static.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def load_and_parse(self):
184184
# If no validators, assume label
185185
method = "label"
186186

187-
# If we have a validator, test the valididy
187+
# If we have a validator, test the validity
188188
else:
189189
if method in StaticRules.validators:
190190
if StaticRules.validators[method].match(value) is None:
@@ -215,7 +215,7 @@ def generate(self, state):
215215
"""
216216

217217
# CA-75599 - check that state has no shared ppns.
218-
# See net.biodevname.has_ppn_quirks() for full reason
218+
# See net.biosdevname.has_ppn_quirks() for full reason
219219
ppns = [ x.ppn for x in state if x.ppn is not None ]
220220
ppn_quirks = ( len(ppns) != len(set(ppns)) )
221221

@@ -311,7 +311,7 @@ def write(self, header = True):
311311
LOG.warning("Method %s not recognised. Ignoring" % (method,))
312312
continue
313313

314-
# If we have a validator, test the valididy
314+
# If we have a validator, test the validity
315315
if method in StaticRules.validators:
316316
if StaticRules.validators[method].match(value) is None:
317317
LOG.warning("Invalid %s value '%s'. Ignoring"

xcp/net/ip.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def ip_link_set_name(src_name, dst_name):
8585
# if the device was up before, bring it back up
8686
if isup:
8787

88-
# Performace note: if we are doing an intermediate rename to
88+
# Performance note: if we are doing an intermediate rename to
8989
# move a device sideways, we shouldn't bring it back until it has
9090
# its final name. However, I can't think of a non-hacky way of doing
9191
# this with the current implementation

xcp/net/mac.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class MAC(object):
4444
@classmethod
4545
def is_valid(cls, addr):
4646
"""
47-
Static method to assertain whether addr is a recognised MAC address or
47+
Static method to ascertain whether addr is a recognised MAC address or
4848
not
4949
"""
5050
try:
@@ -134,7 +134,7 @@ def as_string(self, sep = ".", upper = False):
134134

135135
if sep == ".":
136136
# this is a hack but I cant think of an easy way of
137-
# manipulating self.octetes
137+
# manipulating self.octets
138138
res = "%0.4x.%0.4x.%0.4x" % ( (self.integer >> 32) & 0xffff,
139139
(self.integer >> 16) & 0xffff,
140140
(self.integer ) & 0xffff )
@@ -146,7 +146,7 @@ def as_string(self, sep = ".", upper = False):
146146
res = ':'.join([ "%0.2x" % o for o in self.octets])
147147

148148
else:
149-
raise ValueError("'%s' is not a valid seperator" % sep)
149+
raise ValueError("'%s' is not a valid separator" % sep)
150150

151151
if upper:
152152
return res.upper()

xcp/pci.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ class PCI(object):
5050
@classmethod
5151
def is_valid(cls, addr):
5252
"""
53-
Static method to assertain whether addr is a recognised PCI address
54-
or not
53+
Static method to ascertain whether addr is a recognised PCI address
5554
"""
5655
try:
5756
PCI(addr)

0 commit comments

Comments
 (0)