Skip to content

Commit 5a3c2a9

Browse files
authored
Expand the amount of files checked by codespell (canonical#79)
* Expand files checked by codespell * Bump libs
1 parent c49d395 commit 5a3c2a9

File tree

5 files changed

+36
-31
lines changed

5 files changed

+36
-31
lines changed

lib/charms/operator_libs_linux/v0/apt.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
Repositories can be added with explicit values through a Python constructor.
7979
8080
Example:
81-
8281
```python
8382
repositories = apt.RepositoryMapping()
8483
@@ -91,7 +90,6 @@
9190
`DebianRepository`.
9291
9392
Example:
94-
9593
```python
9694
repositories = apt.RepositoryMapping()
9795
@@ -124,7 +122,7 @@
124122

125123
# Increment this PATCH version before using `charmcraft publish-lib` or reset
126124
# to 0 if you are raising the major API version
127-
LIBPATCH = 10
125+
LIBPATCH = 11
128126

129127

130128
VALID_SOURCE_TYPES = ("deb", "deb-src")
@@ -135,7 +133,7 @@ class Error(Exception):
135133
"""Base class of most errors raised by this library."""
136134

137135
def __repr__(self):
138-
"""String representation of Error."""
136+
"""Represent the Error."""
139137
return "<{}.{} {}>".format(type(self).__module__, type(self).__name__, self.args)
140138

141139
@property
@@ -212,15 +210,15 @@ def __eq__(self, other) -> bool:
212210
) == (other._name, other._version.number)
213211

214212
def __hash__(self):
215-
"""A basic hash so this class can be used in Mappings and dicts."""
213+
"""Return a hash of this package."""
216214
return hash((self._name, self._version.number))
217215

218216
def __repr__(self):
219-
"""A representation of the package."""
217+
"""Represent the package."""
220218
return "<{}.{}: {}>".format(self.__module__, self.__class__.__name__, self.__dict__)
221219

222220
def __str__(self):
223-
"""A human-readable representation of the package."""
221+
"""Return a human-readable representation of the package."""
224222
return "<{}: {}-{}.{} -- {}>".format(
225223
self.__class__.__name__,
226224
self._name,
@@ -267,7 +265,7 @@ def _add(self) -> None:
267265
)
268266

269267
def _remove(self) -> None:
270-
"""Removes a package from the system. Implementation-specific."""
268+
"""Remove a package from the system. Implementation-specific."""
271269
return self._apt("remove", "{}={}".format(self.name, self.version))
272270

273271
@property
@@ -276,7 +274,7 @@ def name(self) -> str:
276274
return self._name
277275

278276
def ensure(self, state: PackageState):
279-
"""Ensures that a package is in a given state.
277+
"""Ensure that a package is in a given state.
280278
281279
Args:
282280
state: a `PackageState` to reconcile the package to
@@ -308,7 +306,7 @@ def state(self) -> PackageState:
308306

309307
@state.setter
310308
def state(self, state: PackageState) -> None:
311-
"""Sets the package state to a given value.
309+
"""Set the package state to a given value.
312310
313311
Args:
314312
state: a `PackageState` to reconcile the package to
@@ -527,11 +525,11 @@ def __init__(self, version: str, epoch: str):
527525
self._epoch = epoch or ""
528526

529527
def __repr__(self):
530-
"""A representation of the package."""
528+
"""Represent the package."""
531529
return "<{}.{}: {}>".format(self.__module__, self.__class__.__name__, self.__dict__)
532530

533531
def __str__(self):
534-
"""A human-readable representation of the package."""
532+
"""Return human-readable representation of the package."""
535533
return "{}{}".format("{}:".format(self._epoch) if self._epoch else "", self._version)
536534

537535
@property
@@ -732,6 +730,7 @@ def add_package(
732730
"""Add a package or list of packages to the system.
733731
734732
Args:
733+
package_names: single package name, or list of package names
735734
name: the name(s) of the package(s)
736735
version: an (Optional) version as a string. Defaults to the latest known
737736
arch: an optional architecture for the package
@@ -788,7 +787,7 @@ def _add(
788787
version: Optional[str] = "",
789788
arch: Optional[str] = "",
790789
) -> Tuple[Union[DebianPackage, str], bool]:
791-
"""Adds a package.
790+
"""Add a package to the system.
792791
793792
Args:
794793
name: the name(s) of the package(s)
@@ -809,7 +808,7 @@ def _add(
809808
def remove_package(
810809
package_names: Union[str, List[str]]
811810
) -> Union[DebianPackage, List[DebianPackage]]:
812-
"""Removes a package from the system.
811+
"""Remove package(s) from the system.
813812
814813
Args:
815814
package_names: the name of a package
@@ -837,7 +836,7 @@ def remove_package(
837836

838837

839838
def update() -> None:
840-
"""Updates the apt cache via `apt-get update`."""
839+
"""Update the apt cache via `apt-get update`."""
841840
check_call(["apt-get", "update"], stderr=PIPE, stdout=PIPE)
842841

843842

@@ -966,7 +965,7 @@ def filename(self):
966965

967966
@filename.setter
968967
def filename(self, fname: str) -> None:
969-
"""Sets the filename used when a repo is written back to diskself.
968+
"""Set the filename used when a repo is written back to disk.
970969
971970
Args:
972971
fname: a filename to write the repository information to.
@@ -1148,7 +1147,7 @@ def _get_key_by_keyid(keyid: str) -> str:
11481147

11491148
@staticmethod
11501149
def _dearmor_gpg_key(key_asc: bytes) -> bytes:
1151-
"""Converts a GPG key in the ASCII armor format to the binary format.
1150+
"""Convert a GPG key in the ASCII armor format to the binary format.
11521151
11531152
Args:
11541153
key_asc: A GPG key in ASCII armor format.
@@ -1172,7 +1171,7 @@ def _dearmor_gpg_key(key_asc: bytes) -> bytes:
11721171

11731172
@staticmethod
11741173
def _write_apt_gpg_keyfile(key_name: str, key_material: bytes) -> None:
1175-
"""Writes GPG key material into a file at a provided path.
1174+
"""Write GPG key material into a file at a provided path.
11761175
11771176
Args:
11781177
key_name: A key name to use for a key file (could be a fingerprint)
@@ -1220,7 +1219,7 @@ def __len__(self) -> int:
12201219
return len(self._repository_map)
12211220

12221221
def __iter__(self) -> Iterable[DebianRepository]:
1223-
"""Iterator magic method for RepositoryMapping."""
1222+
"""Return iterator for RepositoryMapping."""
12241223
return iter(self._repository_map.values())
12251224

12261225
def __getitem__(self, repository_uri: str) -> DebianRepository:

lib/charms/operator_libs_linux/v1/systemd.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,23 @@
6060

6161
# Increment this PATCH version before using `charmcraft publish-lib` or reset
6262
# to 0 if you are raising the major API version
63-
LIBPATCH = 1
63+
LIBPATCH = 2
6464

6565

6666
class SystemdError(Exception):
67+
"""Custom exception for SystemD related errors."""
68+
6769
pass
6870

6971

7072
def _popen_kwargs():
71-
return dict(
72-
stdout=subprocess.PIPE,
73-
stderr=subprocess.STDOUT,
74-
bufsize=1,
75-
universal_newlines=True,
76-
encoding="utf-8",
77-
)
73+
return {
74+
"stdout": subprocess.PIPE,
75+
"stderr": subprocess.STDOUT,
76+
"bufsize": 1,
77+
"universal_newlines": True,
78+
"encoding": "utf-8",
79+
}
7880

7981

8082
def _systemctl(

tests/integration/new_relations/test_new_relations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async def test_no_read_only_endpoint_in_standalone_cluster(ops_test: OpsTest):
7171
"""Test that there is no read-only endpoint in a standalone cluster."""
7272
async with ops_test.fast_forward():
7373
# Ensure the cluster starts with only one member.
74-
# We cant scale down a running cluster to 1 unit because the way
74+
# We can't scale down a running cluster to 1 unit because the way
7575
# Patroni raft implementation works (to scale from 2 units to 1 Patroni
7676
# needs at least one mode unit that run only raft to have quorum).
7777
assert len(ops_test.model.applications[DATABASE_APP_NAME].units) == 1

tests/unit/test_charm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ def test_install_pip_package(self, _call):
493493

494494
_call.side_effect = [None, subprocess.SubprocessError]
495495

496-
# Then test for a succesful install.
496+
# Then test for a successful install.
497497
self.charm._install_pip_package(package)
498498
# Check that check_call was invoked with the correct arguments.
499499
_call.assert_called_once_with(

tox.ini

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ env_list = lint, unit
1010
src_path = {tox_root}/src
1111
tests_path = {tox_root}/tests
1212
;lib_path = {tox_root}/lib/charms/operator_name_with_underscores
13+
test_ha_charm_libs = {tox_root}tests/integration/ha_tests/application-charm/lib
14+
test_rel_charm_libs = {tox_root}tests/integration/new_relations/application-charm/lib
1315
all_path = {[vars]src_path} {[vars]tests_path}
1416

1517
[testenv]
@@ -36,8 +38,10 @@ commands =
3638
description = Check code against coding style standards
3739
commands =
3840
poetry install --only format,lint
39-
poetry run codespell {tox_root}/*.yaml {tox_root}/*.ini {tox_root}/*.md \
40-
{tox_root}/*.toml {tox_root}/*.txt {tox_root}/.github
41+
poetry run codespell {tox_root} --skip {tox_root}/.git --skip {tox_root}/.tox \
42+
--skip {tox_root}/build --skip {tox_root}/lib --skip {tox_root}/venv \
43+
--skip {tox_root}/.mypy_cache --skip {tox_root}/LICENSE --skip {tox_root}/poetry.lock \
44+
--skip {[vars]test_ha_charm_libs} --skip {[vars]test_rel_charm_libs}
4145
# pflake8 wrapper supports config from pyproject.toml
4246
poetry run pflake8 {[vars]all_path}
4347
poetry run isort --check-only --diff {[vars]all_path}

0 commit comments

Comments
 (0)