Skip to content

Commit 97e1529

Browse files
Fix style check failures
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent e2db62f commit 97e1529

File tree

11 files changed

+29
-32
lines changed

11 files changed

+29
-32
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ Release notes
44
Version 32.3.0 - (2025-03-06)
55
-----------------------------
66

7-
- migrate ``os.listdir()`` to ``os.scandir()`` to increase performance
8-
- Fix checksums for empty files
7+
- Fix ``click`` compatibililty issues.
8+
https://github.com/aboutcode-org/commoncode/pull/89
9+
https://github.com/aboutcode-org/commoncode/pull/86
910

1011
Version 32.2.1 - (2025-03-06)
1112
-----------------------------
@@ -41,7 +42,8 @@ Version 32.0.0 - (2024-09-05)
4142
Version 31.2.1 - (2024-05-16)
4243
-----------------------------
4344

44-
- Remove ``commoncode.system.get_etc_os_release_info`` and replace it with ``commoncode.distro_os_release_parser``.
45+
- Remove ``commoncode.system.get_etc_os_release_info`` and replace it with
46+
``commoncode.distro_os_release_parser``.
4547

4648

4749
Version 31.2.0 - (2024-05-16)

src/commoncode/command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ def execute2(
129129
log=TRACE,
130130
):
131131
"""
132-
DEPRECATED: DO NOT USE. Use execute() instead
133132
Run a `cmd_loc` command with the `args` arguments list and return the return
134133
code, the stdout and stderr.
134+
DEPRECATED: DO NOT USE. Use execute() instead
135135
136136
To avoid RAM exhaustion, always write stdout and stderr streams to files.
137137

src/commoncode/datautils.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def attribute(
3333
metadata=None,
3434
): # NOQA
3535
"""
36-
A generic attribute with help metadata and that is not included in the
36+
Return a generic attribute with help metadata and that is not included in the
3737
representation by default.
3838
"""
3939
metadata = metadata or dict()
@@ -67,7 +67,7 @@ def Boolean(
6767
help=None,
6868
): # NOQA
6969
"""
70-
A boolean attribute.
70+
Return a boolean attribute.
7171
"""
7272
return attribute(
7373
default=default,
@@ -94,7 +94,7 @@ def TriBoolean(
9494
help=None,
9595
): # NOQA
9696
"""
97-
A tri-boolean attribute with possible values of None, True and False.
97+
Return a tri-boolean attribute with possible values of None, True and False.
9898
"""
9999
return attribute(
100100
default=default,
@@ -121,7 +121,7 @@ def String(
121121
help=None,
122122
): # NOQA
123123
"""
124-
A string attribute.
124+
Return a string attribute.
125125
"""
126126
return attribute(
127127
default=default,
@@ -148,7 +148,7 @@ def Integer(
148148
help=None,
149149
): # NOQA
150150
"""
151-
An integer attribute.
151+
Return an integer attribute.
152152
"""
153153
converter = converter or attr.converters.optional(int)
154154
return attribute(
@@ -176,7 +176,7 @@ def Float(
176176
help=None,
177177
): # NOQA
178178
"""
179-
A float attribute.
179+
Return a float attribute.
180180
"""
181181
return attribute(
182182
default=default,
@@ -204,7 +204,7 @@ def List(
204204
help=None,
205205
): # NOQA
206206
"""
207-
A list attribute: the optional item_type defines the type of items it stores.
207+
Return a list attribute: the optional item_type defines the type of items it stores.
208208
"""
209209
if default is attr.NOTHING:
210210
default = attr.Factory(list)
@@ -235,7 +235,7 @@ def Mapping(
235235
label=None,
236236
): # NOQA
237237
"""
238-
A mapping attribute: the optional value_type defines the type of values it
238+
Return a mapping attribute: the optional value_type defines the type of values it
239239
stores. The key is always a string.
240240
241241
Notes: in Python 2 the type is Dict as there is no typing available for
@@ -274,7 +274,7 @@ def Date(
274274
help=None,
275275
): # NOQA
276276
"""
277-
A date attribute. It always serializes to an ISO date string.
277+
Return a date attribute. It always serializes to an ISO date string.
278278
Behavior is TBD and for now this is exactly a string.
279279
"""
280280
return String(

src/commoncode/dict_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ def sparsify(d):
1818
Example:
1919
>>> sparsify({1: 3, 4: 5})
2020
{1: 3, 4: 5}
21+
2122
"""
2223
e = d.copy()
2324
d.update(e)

src/commoncode/fetch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def download_url(url, file_name=None, verify=True, timeout=10):
5454

5555
def ping_url(url):
5656
"""
57-
Returns True is `url` is reachable.
57+
Return True is `url` is reachable.
5858
"""
5959
try:
6060
from urlib.request import urlopen

src/commoncode/fileutils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def create_dir(location):
7070

7171
if os.path.exists(location):
7272
if not os.path.isdir(location):
73-
err = "Cannot create directory: existing file " "in the way " "%(location)s."
73+
err = "Cannot create directory: existing file in the way %(location)s."
7474
raise OSError(err % locals())
7575
else:
7676
# may fail on win if the path is too long
@@ -140,7 +140,7 @@ def prepare_path(pth):
140140

141141

142142
def is_posixpath(location):
143-
"""
143+
r"""
144144
Return True if the `location` path is likely a POSIX-like path using POSIX path
145145
separators (slash or "/")or has no path separator.
146146
@@ -164,7 +164,7 @@ def is_posixpath(location):
164164

165165

166166
def as_posixpath(location):
167-
"""
167+
r"""
168168
Return a POSIX-like path using POSIX path separators (slash or "/") for a
169169
`location` path. This converts Windows paths to look like POSIX paths: Python
170170
accepts gracefully POSIX paths on Windows.
@@ -174,7 +174,7 @@ def as_posixpath(location):
174174

175175

176176
def as_winpath(location):
177-
"""
177+
r"""
178178
Return a Windows-like path using Windows path separators (backslash or "\") for a
179179
`location` path.
180180
"""

src/commoncode/resource.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ def depth_walk(
120120
directory recursively up to ``max_depth`` path segments extending from the
121121
``root_location``. The behaviour is similar of ``os.walk``.
122122
123-
Arguments:
124-
125123
- root_location: Absolute, normalized path for the directory to be walked
126124
- max_depth: positive integer for fixed depth limit. 0 for no limit.
127125
- skip_ignored: Callback function that takes a location as argument and
@@ -829,7 +827,7 @@ def _dump_resource(self, resource):
829827

830828
if not cache_location:
831829
raise TypeError(
832-
"Resource cannot be dumped to disk and is used only" f"in memory: {resource}"
830+
f"Resource cannot be dumped to disk and is used onlyin memory: {resource}"
833831
)
834832

835833
# TODO: consider messagepack or protobuf for compact/faster processing?
@@ -1173,7 +1171,7 @@ def type(self, value):
11731171

11741172
@classmethod
11751173
def build_path(cls, root_location, location):
1176-
"""
1174+
r"""
11771175
Return a POSIX path string (using "/" separators) of ``location`` relative
11781176
to ``root_location`. Both locations are absolute native locations.
11791177
The returned path has no leading and trailing slashes. The first segment

src/commoncode/testcase.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,15 @@ def get_test_loc(
6969

7070
if not path.exists(test_data_dir):
7171
raise IOError(
72-
"[Errno 2] No such directory: test_data_dir not found:"
73-
" '%(test_data_dir)s'" % locals()
72+
"[Errno 2] No such directory: test_data_dir not found: '%(test_data_dir)s'" % locals()
7473
)
7574

7675
tpath = to_os_native_path(test_path)
7776
test_loc = path.abspath(path.join(test_data_dir, tpath))
7877

7978
if must_exist and not path.exists(test_loc):
8079
raise IOError(
81-
"[Errno 2] No such file or directory: " "test_path not found: '%(test_loc)s'" % locals()
80+
"[Errno 2] No such file or directory: test_path not found: '%(test_loc)s'" % locals()
8281
)
8382

8483
return test_loc

src/commoncode/text.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828

2929
def lines(s):
30-
"""
30+
r"""
3131
Split a string in lines using the following conventions:
3232
- a line ending \r\n or \n is a separator and yields a new list element
3333
- empty lines or lines with only white spaces are not returned.
@@ -54,7 +54,7 @@ def nopunc():
5454

5555
def nopunctuation(text):
5656
"""
57-
Replaces any non alphanum symbol (i.e. punctuation) in text with space.
57+
Replace any non alphanum symbol (i.e. punctuation) in text with space.
5858
Preserve the characters offsets by replacing punctuation with spaces.
5959
Warning: this also drops line endings.
6060
"""
@@ -81,7 +81,7 @@ def unixlinesep(text, preserve=False):
8181

8282
def nolinesep(text):
8383
"""
84-
Removes line separators, replacing them with spaces.
84+
Remove line separators, replacing them with spaces.
8585
"""
8686
if not isinstance(text, str):
8787
text = as_unicode(text)

src/commoncode/urn.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
urn:dje:component:dropbear:
6464
6565
The product object type syntax is the same as the component syntax.
66+
6667
"""
6768

6869
from urllib.parse import quote_plus

tests/test_fileutils.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828

2929
@skip("Somehow permissions tests do not work OK yet on Python 3")
3030
class TestPermissionsDeletions(FileBasedTesting):
31-
"""
32-
This is failing for now on Python 3
33-
"""
34-
3531
test_data_dir = os.path.join(os.path.dirname(__file__), "data")
3632

3733
def test_delete_unwritable_directory_and_files(self):

0 commit comments

Comments
 (0)