Skip to content

Commit 1c1bf20

Browse files
JacobCallahanColeHiggins2
authored andcommitted
Introduce docstring standards for Ruff
Most rules are used, but a few are ignored for style.
1 parent 9bae6b8 commit 1c1bf20

12 files changed

+379
-435
lines changed

docs/create_user_plain.py

-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def get_organization_id(server_config, label):
5555
:param label: A string label that will be used when searching. Every
5656
organization should have a unique label.
5757
:returns: An organization ID. (Typically an integer.)
58-
5958
"""
6059
response = requests.get(
6160
f'{server_config["url"]}/katello/api/v2/organizations',

nailgun/client.py

+8-12
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def _content_type_is_json(kwargs):
5858
:param kwargs: A ``dict``. The keyword args supplied to :func:`request` or
5959
one of the convenience functions like it.
6060
:returns: ``True`` or ``False``
61-
6261
"""
6362
if 'headers' in kwargs and 'content-type' in kwargs['headers']:
6463
return kwargs['headers']['content-type'].lower() == 'application/json'
@@ -75,7 +74,6 @@ def _set_content_type(kwargs):
7574
:param kwargs: A ``dict``. The keyword args supplied to :func:`request` or
7675
one of the convenience functions like it.
7776
:return: Nothing. ``kwargs`` is modified in-place.
78-
7977
"""
8078
if 'files' in kwargs:
8179
return # requests will automatically set the content-type
@@ -85,7 +83,7 @@ def _set_content_type(kwargs):
8583

8684

8785
def _truncate_data(data, max_len=500):
88-
"""Truncate data to a max length"""
86+
"""Truncate data to a max length."""
8987
if isinstance(data, str | bytes):
9088
if len(data) > max_len:
9189
return f"{data[:max_len - 3]}..."
@@ -103,7 +101,6 @@ def _log_request(method, url, kwargs, data=None, params=None):
103101
one can pass to ``requests.request``.
104102
105103
:return: Nothing is returned.
106-
107104
"""
108105
logger.debug(
109106
'Making HTTP %s request to %s with %s, %s and %s.',
@@ -123,7 +120,6 @@ def _log_response(response):
123120
the object returned is logged.
124121
125122
:return: Nothing is returned.
126-
127123
"""
128124
message = f'Received HTTP {response.status_code} response: {response.text}'
129125
if not response.ok:
@@ -133,7 +129,7 @@ def _log_response(response):
133129

134130

135131
def request(method, url, **kwargs):
136-
"""A wrapper for ``requests.request``."""
132+
"""Wrap ``requests.request``."""
137133
_set_content_type(kwargs)
138134
if _content_type_is_json(kwargs) and kwargs.get('data') is not None:
139135
kwargs['data'] = dumps(kwargs['data'])
@@ -144,7 +140,7 @@ def request(method, url, **kwargs):
144140

145141

146142
def head(url, **kwargs):
147-
"""A wrapper for ``requests.head``."""
143+
"""Wrap ``requests.head``."""
148144
_set_content_type(kwargs)
149145
if _content_type_is_json(kwargs) and kwargs.get('data') is not None:
150146
kwargs['data'] = dumps(kwargs['data'])
@@ -155,7 +151,7 @@ def head(url, **kwargs):
155151

156152

157153
def get(url, params=None, **kwargs):
158-
"""A wrapper for ``requests.get``."""
154+
"""Wrap ``requests.get``."""
159155
_set_content_type(kwargs)
160156
if _content_type_is_json(kwargs) and kwargs.get('data') is not None:
161157
kwargs['data'] = dumps(kwargs['data'])
@@ -166,7 +162,7 @@ def get(url, params=None, **kwargs):
166162

167163

168164
def post(url, data=None, json=None, **kwargs):
169-
"""A wrapper for ``requests.post``."""
165+
"""Wrap ``requests.post``."""
170166
_set_content_type(kwargs)
171167
if _content_type_is_json(kwargs) and data is not None:
172168
data = dumps(data)
@@ -177,7 +173,7 @@ def post(url, data=None, json=None, **kwargs):
177173

178174

179175
def put(url, data=None, **kwargs):
180-
"""A wrapper for ``requests.put``. Sends a PUT request."""
176+
"""Wrap ``requests.put``. Sends a PUT request."""
181177
_set_content_type(kwargs)
182178
if _content_type_is_json(kwargs) and data is not None:
183179
data = dumps(data)
@@ -188,7 +184,7 @@ def put(url, data=None, **kwargs):
188184

189185

190186
def patch(url, data=None, **kwargs):
191-
"""A wrapper for ``requests.patch``. Sends a PATCH request."""
187+
"""Wrap ``requests.patch``. Sends a PATCH request."""
192188
_set_content_type(kwargs)
193189
if _content_type_is_json(kwargs) and data is not None:
194190
data = dumps(data)
@@ -199,7 +195,7 @@ def patch(url, data=None, **kwargs):
199195

200196

201197
def delete(url, **kwargs):
202-
"""A wrapper for ``requests.delete``. Sends a DELETE request."""
198+
"""Wrap ``requests.delete``. Sends a DELETE request."""
203199
_set_content_type(kwargs)
204200
if _content_type_is_json(kwargs) and kwargs.get('data') is not None:
205201
kwargs['data'] = dumps(kwargs['data'])

nailgun/config.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class ConfigFileError(Exception):
2121
.. WARNING:: This class will likely be moved to a separate Python package
2222
in a future release of NailGun. Be careful about making references to
2323
this class, as those references will likely need to be changed.
24-
2524
"""
2625

2726

@@ -40,7 +39,6 @@ def _get_config_file_path(xdg_config_dir, xdg_config_file):
4039
:returns: A ``str`` path to a configuration file.
4140
:raises nailgun.config.ConfigFileError: When no configuration file can be
4241
found.
43-
4442
"""
4543
for config_dir in BaseDirectory.load_config_paths(xdg_config_dir):
4644
path = join(config_dir, xdg_config_file)
@@ -91,7 +89,6 @@ class BaseServerConfig:
9189
.. WARNING:: This class will likely be moved to a separate Python package
9290
in a future release of NailGun. Be careful about making references to
9391
this class, as those references will likely need to be changed.
94-
9592
"""
9693

9794
# Used to lock access to the configuration file when performing certain
@@ -110,6 +107,7 @@ def __init__(self, url, auth=None, version=None):
110107
self.version = parse(version)
111108

112109
def __repr__(self):
110+
"""Return a string representation of the object."""
113111
attrs = vars(self).copy()
114112
if "version" in attrs:
115113
attrs["version"] = str(attrs.pop("version"))
@@ -228,7 +226,6 @@ class ServerConfig(BaseServerConfig):
228226
229227
:param verify: A boolean. Should SSL be verified when communicating with
230228
the server? No instance attribute is created if no value is provided.
231-
232229
"""
233230

234231
# It's OK that this class has only one public method. This class is

0 commit comments

Comments
 (0)