Skip to content

Commit 170eddb

Browse files
[STYLE] Fixes and style improvements (- WIP PR #448 -)
Changes in file .coderabbit.yaml: * reviewed and approved sugested grammar changes (see AI policy requirements for changes) * implemented approved grammar changes Changes in file .github/actions/checkout-and-rebuild/action.yml: * minor changes Changes in file pyproject.toml: * fixed a version typo Changes in file tests/MulticastUDPClient.py: * fixed a version header Changes in file tests/__init__.py: * minor fixes Changes in file tests/test_basic.py: * fixed a version header Changes in file tests/test_build.py: * fixed a version header Changes in file tests/test_deps.py: * fixed a version header Changes in file tests/test_extra.py: * minor style changes Changes in file tests/test_hear_cleanup.py: * minor style changes Changes in file tests/test_hear_keyboard_interrupt.py: * minor style changes Changes in file tests/test_manifest.py: * minor style changes Changes in file tox.ini: * more fixes and cleanup
1 parent 2886b9a commit 170eddb

File tree

13 files changed

+51
-43
lines changed

13 files changed

+51
-43
lines changed

.coderabbit.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ reviews:
8686
message prefixed with "[DOCUMENTATION] "
8787
- label: CI
8888
instructions: >-
89-
Apply whenever project CI/CD components (namely GitHub Action source-code) is
89+
Apply whenever any project CI/CD components (namely GitHub Action source-code) are
9090
updated by the PR/MR. Also apply when PR contains a commit with a commit
9191
message prefixed with "[CI] "
9292
- label: Linter
@@ -179,8 +179,8 @@ reviews:
179179
4. Consider these 'requirements.txt' files the records of truth regarding project
180180
dependencies.
181181
5. Consider the 'requirements.txt' file in the base of the git repository
182-
(e.g., './requirements.txt') the required python dependencies regarding Multicast project
183-
dependencies.
182+
(e.g., './requirements.txt') the required python dependencies regarding Multicast
183+
project dependencies.
184184
- path: tests/requirements.txt
185185
instructions: >-
186186
1. The multicast project's own dependencies are recorded in './requirements.txt'

.github/actions/checkout-and-rebuild/action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,22 @@ inputs:
4040
required: true
4141
outputs:
4242
branch-name:
43-
description: "The name of the branch that was checked-out"
43+
description: "The name of the branch that was checked-out."
4444
value: ${{ steps.output_branch_name.outputs.branch-name || '' }}
4545
sha:
46-
description: "The SHA of the commit checked-out"
46+
description: "The SHA of the commit checked-out."
4747
value: ${{ steps.output_sha.outputs.sha || 'HEAD' }}
4848
python-version:
4949
description: "The python version that was used in the run."
5050
value: ${{ steps.cp313.outputs.python-version || '' }}
5151
python-path:
52-
description: "The python version that was installed in the run"
52+
description: "Absolute path to the Python executable installed for the run."
5353
value: ${{ steps.cp313.outputs.python-path }}
5454
artifact-name:
5555
description: "The downloaded artifact-name"
5656
value: "multicast-build-${{ steps.output_sha.outputs.sha }}.zip"
5757
artifact-files:
58-
description: "The downloaded artifact-files"
58+
description: "The downloaded artifact-files."
5959
value: ${{ steps.output_artifact_files.outputs.files }}
6060

6161
runs:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ keywords = ["multicast", "RFC-1112", "udp-protocol", "network-programming", "POS
1010
license-files = ["LICENSE.md"]
1111
maintainers = [{ "name" = "reactive-firewall", "email" = "[email protected]" }]
1212
name = "multicast"
13-
requires-python = ">=3.9.6, !=3.9.7, !=3.9.8, !=3.9.8, !=3.9.10, !=3.9.11, !=3.9.12, !=3.9.13, !=3.9.14, !=3.9.15, !=3.9.16, !=3.9.17, !=3.9.18, !=3.9.19, !=3.13.0, <3.14.0"
13+
requires-python = ">=3.9.6, !=3.9.7, !=3.9.8, !=3.9.9, !=3.9.10, !=3.9.11, !=3.9.12, !=3.9.13, !=3.9.14, !=3.9.15, !=3.9.16, !=3.9.17, !=3.9.18, !=3.9.19, !=3.13.0, <3.14.0"
1414
scripts = { "multicast" = "multicast.__main__:cli" }
1515
version = "v2.0.9a7"
1616

tests/MulticastUDPClient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /usr/bin/env python
1+
#! /usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
# Multicast Python Module (Testing)

tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
>>> output = _tests.get_test_suite()
6161
>>> output is not None
6262
True
63-
>>> type(output) == type(_unittest.TestSuite())
63+
>>> isinstance(output, _unittest.TestSuite)
6464
True
6565
>>>
6666

tests/test_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /usr/bin/env python
1+
#! /usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
# Python Test Repo Template

tests/test_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /usr/bin/env python
1+
#! /usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
# Multicast PEP-517 Tests

tests/test_deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#! /usr/bin/env python
1+
#! /usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

44
# Multicast Python Module (Testing)

tests/test_extra.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
raise ImportError("[CWE-758] Failed to import test context") from baton
5757

5858

59-
_has_docs: bool = False
59+
_HAS_DOCS: bool = False
6060
"""
6161
This module optionally provides extra test cases for the docs.utils module, focusing on the
6262
utils.sanitize_url method for url encoding.
@@ -76,12 +76,12 @@
7676
"""
7777

7878

79-
if not _has_docs:
79+
if not _HAS_DOCS:
8080
try:
8181
import docs.utils
82-
_has_docs = True
82+
_HAS_DOCS = True
8383
except ImportError: # pragma: no branch
84-
_has_docs = False
84+
_HAS_DOCS = False
8585

8686

8787
def onlyIfHasDocs(has_docs: bool) -> callable:
@@ -118,7 +118,7 @@ def decorator(cls: callable) -> callable:
118118

119119

120120
@context.markWithMetaTag("extra", "security")
121-
@onlyIfHasDocs(has_docs=_has_docs)
121+
@onlyIfHasDocs(has_docs=_HAS_DOCS)
122122
class ExtraDocsUtilsTestSuite(context.BasicUsageTestSuite):
123123
"""Test cases for docs.utils module."""
124124

tests/test_hear_cleanup.py

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,20 @@ def test_cleanup_on_exit(self) -> None:
177177
def get_default_ip() -> str:
178178
"""Get the default IP address of the machine.
179179
180+
Determines the machine's default IP address by creating a UDP socket connection
181+
to a reserved test IP address and retrieving the local socket address.
182+
183+
Uses 203.0.113.1 (TEST-NET-3) for RFC 5737 compliance. Port 59095 is chosen as an
184+
arbitrary high port number.
185+
186+
Args:
187+
None
188+
180189
Returns:
181190
str: The IP address of the default network interface.
182191
183-
Note:
184-
Uses 203.0.113.1 (TEST-NET-3) for RFC 5737 compliance.
185-
Port 59095 is chosen as an arbitrary high port number.
192+
Raises:
193+
CommandExecutionError: If the IP address cannot be determined.
186194
"""
187195
s = None
188196
try:
@@ -192,7 +200,7 @@ def get_default_ip() -> str:
192200
s.connect(("203.0.113.1", 59095))
193201
# Get the IP address of the default interface
194202
ip = s.getsockname()[0]
195-
except socket.error as _cause:
203+
except socket.error as _cause: # pragma: no branch
196204
raise multicast.exceptions.CommandExecutionError("Failed to determine IP", 69) from _cause
197205
finally:
198206
if s is not None:
@@ -202,8 +210,17 @@ def get_default_ip() -> str:
202210
def test_should_invoke_kill_func_when_handle_error_called(self) -> None:
203211
"""Test that kill_func calls shutdown on the server instance.
204212
205-
Verifies that the server properly handles requests without
213+
Verifies that the server properly handles mocked requests with
206214
the STOP command and calls the kill_func to free up server resources.
215+
216+
Args:
217+
None (self is implicit)
218+
219+
Returns:
220+
None
221+
222+
Raises:
223+
AssertionError: If the test conditions are not met.
207224
"""
208225
theResult = False
209226
fail_fixture = "Mock(STOP) --> Handler-HEAR --X shutdown"
@@ -212,7 +229,7 @@ def test_should_invoke_kill_func_when_handle_error_called(self) -> None:
212229
self.assertIsNotNone(_fixture_port_num)
213230
self.assertIsInstance(_fixture_port_num, int)
214231
# Create an instance of McastServer
215-
server_address = ('224.0.0.1', _fixture_port_num)
232+
server_address = (self.TEST_MULTICAST_GROUP, _fixture_port_num)
216233
self.server = multicast.hear.McastServer(server_address, None, False)
217234
self.server.shutdown = MagicMock() # Mock the shutdown method
218235
client_address = (self.get_default_ip(), _fixture_port_num)

0 commit comments

Comments
 (0)