Skip to content

Commit 312b508

Browse files
committed
handwritten: Fix D212 Multi-line docstring summary should start at the first line
1 parent 729d631 commit 312b508

34 files changed

+273
-556
lines changed

src/handwritten/_bitfield_utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
def enum_bitfield_to_list(bitfield_value, bitfield_enum_type, actual_enum_type):
2-
"""
3-
Converts a bitfield value to a list of enums.
2+
"""Converts a bitfield value to a list of enums.
43
54
Args:
65
bitfield_value (int): Specifies the value of the bitfield.
@@ -20,8 +19,7 @@ def enum_bitfield_to_list(bitfield_value, bitfield_enum_type, actual_enum_type):
2019

2120

2221
def enum_list_to_bitfield(enum_list, bitfield_enum_type):
23-
"""
24-
Converts a list of enums to a bitfield value.
22+
"""Converts a list of enums to a bitfield value.
2523
2624
Args:
2725
enum_list (List[enum.Enum]): Specifies the list of enums.

src/handwritten/_install_daqmx.py

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737

3838

3939
def _parse_version(version: str) -> tuple[int, ...]:
40-
"""
41-
Split the version string into a tuple of integers.
40+
"""Split the version string into a tuple of integers.
4241
4342
>>> _parse_version("23.8.0")
4443
(23, 8, 0)
@@ -57,10 +56,7 @@ def _parse_version(version: str) -> tuple[int, ...]:
5756

5857

5958
def _get_daqmx_installed_version() -> str | None:
60-
"""
61-
Check for existing installation of NI-DAQmx.
62-
63-
"""
59+
"""Check for existing installation of NI-DAQmx."""
6460
if sys.platform.startswith("win"):
6561
try:
6662
_logger.debug("Reading the registry entries to get installed DAQmx version")
@@ -130,10 +126,7 @@ def _get_daqmx_installed_version() -> str | None:
130126
# Creating a temp file that we then close and yield - this is used to allow subprocesses to access
131127
@contextlib.contextmanager
132128
def _multi_access_temp_file(*, suffix: str = ".exe", delete: bool = True) -> Generator[str]:
133-
"""
134-
Context manager for creating a temporary file.
135-
136-
"""
129+
"""Context manager for creating a temporary file."""
137130
try:
138131
temp_file = tempfile.NamedTemporaryFile(suffix=suffix, delete=False, mode="w")
139132
temp_file.close()
@@ -161,8 +154,7 @@ def _multi_access_temp_file(*, suffix: str = ".exe", delete: bool = True) -> Gen
161154
def _load_data(
162155
json_data: str, platform: str
163156
) -> tuple[str | None, str | None, str | None, list[str] | None]:
164-
"""
165-
Load data from JSON string and extract Windows metadata.
157+
"""Load data from JSON string and extract Windows metadata.
166158
167159
>>> json_data = '{"Windows": [{"Location": "path/to/windows/driver", "Version": "24.0", "Release": "2024Q1", "supportedOS": ["Windows 11"]}], "Linux": []}'
168160
>>> _load_data(json_data, "Windows")
@@ -214,10 +206,7 @@ def _load_data(
214206
def _get_driver_details(
215207
platform: str,
216208
) -> tuple[str | None, str | None, str | None, list[str] | None]:
217-
"""
218-
Parse the JSON data and retrieve the download link and version information.
219-
220-
"""
209+
"""Parse the JSON data and retrieve the download link and version information."""
221210
try:
222211
with pkg_resources.open_text(__package__, METADATA_FILE) as json_file:
223212
_logger.debug("Opening the metadata file %s.", METADATA_FILE)
@@ -234,10 +223,7 @@ def _get_driver_details(
234223

235224

236225
def _install_daqmx_driver_windows_core(download_url: str) -> None:
237-
"""
238-
Download and launch NI-DAQmx Driver installation in an interactive mode
239-
240-
"""
226+
"""Download and launch NI-DAQmx Driver installation in an interactive mode"""
241227
_validate_download_url(download_url)
242228
try:
243229
with _multi_access_temp_file() as temp_file:
@@ -263,10 +249,7 @@ def _install_daqmx_driver_windows_core(download_url: str) -> None:
263249

264250

265251
def _install_daqmx_driver_linux_core(download_url: str, release: str) -> None:
266-
"""
267-
Download NI Linux Device Drivers and install NI-DAQmx on Linux OS
268-
269-
"""
252+
"""Download NI Linux Device Drivers and install NI-DAQmx on Linux OS"""
270253
if sys.platform.startswith("linux"):
271254
_validate_download_url(download_url)
272255
try:
@@ -330,10 +313,7 @@ def _validate_download_url(download_url: str) -> None:
330313

331314

332315
def _ask_user_confirmation(user_message: str) -> bool:
333-
"""
334-
Prompt for user confirmation
335-
336-
"""
316+
"""Prompt for user confirmation"""
337317
while True:
338318
response = input(user_message + " (yes/no): ").strip().lower()
339319
if response in ["yes", "y"]:
@@ -349,10 +329,7 @@ def _upgrade_daqmx_user_confirmation(
349329
latest_version: str,
350330
release: str,
351331
) -> bool:
352-
"""
353-
Confirm with the user and return the user response.
354-
355-
"""
332+
"""Confirm with the user and return the user response."""
356333
_logger.debug("Entering _upgrade_daqmx_user_confirmation")
357334
installed_parts = _parse_version(installed_version)
358335
latest_parts = _parse_version(latest_version)
@@ -371,21 +348,15 @@ def _fresh_install_daqmx_user_confirmation(
371348
latest_version: str,
372349
release: str,
373350
) -> bool:
374-
"""
375-
Confirm with the user and return the user response.
376-
377-
"""
351+
"""Confirm with the user and return the user response."""
378352
_logger.debug("Entering _fresh_install_daqmx_user_confirmation")
379353
return _ask_user_confirmation(
380354
f"Latest NI-DAQmx version available is {latest_version} ({release}). Do you want to install?"
381355
)
382356

383357

384358
def _is_distribution_supported() -> None:
385-
"""
386-
Raises an exception if the linux distribution and its version are not supported.
387-
388-
"""
359+
"""Raises an exception if the linux distribution and its version are not supported."""
389360
if sys.platform.startswith("linux"):
390361
dist_name = distro.id()
391362
dist_version = distro.version()
@@ -409,10 +380,7 @@ def _is_distribution_supported() -> None:
409380

410381

411382
def _install_daqmx_driver():
412-
"""
413-
Install the NI-DAQmx driver.
414-
415-
"""
383+
"""Install the NI-DAQmx driver."""
416384
if sys.platform.startswith("win"):
417385
_logger.info("Windows platform detected")
418386
platform = "Windows"
@@ -453,10 +421,7 @@ def _install_daqmx_driver():
453421

454422

455423
def installdriver() -> None:
456-
"""
457-
Download and launch NI-DAQmx Driver installation in an interactive mode.
458-
459-
"""
424+
"""Download and launch NI-DAQmx Driver installation in an interactive mode."""
460425
try:
461426
_install_daqmx_driver()
462427
except click.ClickException:

src/handwritten/_lib.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838

3939

4040
class c_bool32(ctypes.c_uint):
41-
"""
42-
Specifies a custom ctypes data type to represent 32-bit booleans.
43-
"""
41+
"""Specifies a custom ctypes data type to represent 32-bit booleans."""
4442

4543
# typeshed specifies that _SimpleCData[_T].value is an instance variable with type _T, so
4644
# accessing it with the descriptor protocol via its class results in "error: Access to generic
@@ -58,10 +56,8 @@ def _setter(self, val):
5856

5957

6058
class CtypesByteString:
61-
"""
62-
Custom argtype that automatically converts unicode strings to encoding
63-
used by the DAQmx C API DLL in Python 3.
64-
"""
59+
"""Custom argtype that automatically converts unicode strings to encoding
60+
used by the DAQmx C API DLL in Python 3."""
6561

6662
@classmethod
6763
def from_param(cls, param):
@@ -74,8 +70,7 @@ def from_param(cls, param):
7470

7571

7672
def wrapped_ndpointer(*args, **kwargs):
77-
"""
78-
Specifies an ndpointer type that wraps numpy.ctypeslib.ndpointer and
73+
"""Specifies an ndpointer type that wraps numpy.ctypeslib.ndpointer and
7974
allows a value of None to be passed to an argument of that type.
8075
8176
Taken from http://stackoverflow.com/questions/32120178
@@ -91,8 +86,7 @@ def from_param(cls, obj):
9186

9287

9388
class DaqFunctionImporter:
94-
"""
95-
Wraps the function getter function of a ctypes library.
89+
"""Wraps the function getter function of a ctypes library.
9690
9791
Allows the NI-DAQmx Python API to fail elegantly if a function is not
9892
supported in the current version of the API.
@@ -132,17 +126,13 @@ def __getattr__(self, function):
132126

133127

134128
def get_encoding_from_locale() -> str:
135-
"""
136-
Gets the current locale encoding handling cases where it is unset.
137-
"""
129+
"""Gets the current locale encoding handling cases where it is unset."""
138130
_, encoding = locale.getlocale()
139131
return encoding or "ascii"
140132

141133

142134
class DaqLibImporter:
143-
"""
144-
Encapsulates NI-DAQmx library importing and handle type parsing logic.
145-
"""
135+
"""Encapsulates NI-DAQmx library importing and handle type parsing logic."""
146136

147137
def __init__(self):
148138
self._windll = None
@@ -178,9 +168,7 @@ def encoding(self):
178168
return self._encoding
179169

180170
def _import_lib(self):
181-
"""
182-
Determines the location of and loads the NI-DAQmx CAI DLL.
183-
"""
171+
"""Determines the location of and loads the NI-DAQmx CAI DLL."""
184172
self._windll = None
185173
self._cdll = None
186174
self._encoding = None

src/handwritten/_linux_installation_commands.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ class DistroInfo:
7979
def get_linux_installation_commands(
8080
_directory_to_extract_to: str, dist_name: str, dist_version: str, _release_string: str
8181
) -> list[list[str]]:
82-
"""
83-
Get the installation commands for Linux based on the distribution.
84-
85-
"""
82+
"""Get the installation commands for Linux based on the distribution."""
8683
if dist_name not in LINUX_COMMANDS:
8784
raise ValueError(f"Unsupported distribution '{dist_name}'")
8885

0 commit comments

Comments
 (0)