Skip to content

Commit 7cdfa1b

Browse files
[STYLE] Refactoring for modern python code-style (e.g. 3.9+) (- WIP #134 -)
Additions with file .style.yapf: - added YAPF style guides for CEP-8 style Changes in file docs/conf.py: - imporved style Changes in file docs/utils.py: - imporved style Changes in file multicast/__init__.py: - imporved style Changes in file multicast/__main__.py: - imporved style Changes in file multicast/env.py: - imporved style Changes in file multicast/exceptions.py: - imporved style Changes in file multicast/hear.py: - imporved style Changes in file multicast/recv.py: - imporved style Changes in file multicast/send.py: - imporved style Changes in file multicast/skt.py: - imporved style Changes in file tests/MulticastUDPClient.py: - imporved style Changes in file tests/__init__.py: - imporved style Changes in file tests/context.py: - imporved style Changes in file tests/profiling.py: - imporved style Changes in file tests/test_build.py: - renamed test suites - slight style improvements Changes in file tests/test_deps.py: - renamed test suites - slight style improvements Changes in file tests/test_fuzz.py: Unknown Changes Changes in file tests/test_hear_cleanup.py: Unknown Changes Changes in file tests/test_hear_data_processing.py: Unknown Changes Changes in file tests/test_hear_keyboard_interrupt.py: Unknown Changes Changes in file tests/test_hear_server.py: Unknown Changes Changes in file tests/test_hear_server_activate.py: Unknown Changes Changes in file tests/test_install_requires.py: Unknown Changes Changes in file tests/test_manifest.py: Unknown Changes Changes in file tests/test_usage.py: Unknown Changes
1 parent 931e3b7 commit 7cdfa1b

26 files changed

+837
-496
lines changed

.style.yapf

Lines changed: 402 additions & 0 deletions
Large diffs are not rendered by default.

docs/conf.py

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
'v2.0'
3737
"""
3838

39-
4039
import sys
4140
import os
4241
from urllib.parse import quote
@@ -72,17 +71,25 @@
7271
# for md us 'autodoc2' (pip install sphinx-autodoc2)
7372
# for rst use 'sphinx.ext.autodoc'
7473
extensions = [
75-
"""sphinx.ext.napoleon""", """autodoc2""", """sphinx.ext.autosectionlabel""",
76-
"""sphinx.ext.githubpages""", """myst_parser""", """sphinx_design""",
77-
"""sphinx.ext.autosummary""", """sphinx.ext.doctest""", """sphinx.ext.todo""",
78-
"""sphinx.ext.linkcode""", """sphinx.ext.viewcode""", """sphinx.ext.intersphinx""",
74+
"""sphinx.ext.napoleon""",
75+
"""autodoc2""",
76+
"""sphinx.ext.autosectionlabel""",
77+
"""sphinx.ext.githubpages""",
78+
"""myst_parser""",
79+
"""sphinx_design""",
80+
"""sphinx.ext.autosummary""",
81+
"""sphinx.ext.doctest""",
82+
"""sphinx.ext.todo""",
83+
"""sphinx.ext.linkcode""",
84+
"""sphinx.ext.viewcode""",
85+
"""sphinx.ext.intersphinx""",
7986
]
8087

8188
# for md auto-docs
8289
autodoc2_packages = [
90+
"tests",
8391
"multicast",
8492
"tests.context",
85-
"tests",
8693
]
8794

8895
autodoc2_render_plugin = "myst"
@@ -92,11 +99,11 @@
9299

93100
# The suffix of source filenames.
94101
source_suffix = {
102+
".yml": "yaml",
95103
".md": "markdown",
96104
".txt": "markdown",
97-
".rst": "restructuredtext",
98-
".yml": "yaml",
99105
"Makefile": "makefile",
106+
".rst": "restructuredtext",
100107
}
101108

102109
# The encoding of source files. Official sphinx docs recommend utf-8-sig.
@@ -132,8 +139,18 @@
132139
# List of patterns, relative to source directory, that match files and
133140
# directories to ignore when looking for source files.
134141
exclude_patterns = [
135-
"_build", ".github", ".circleci", "codecov_env", ".DS_Store", "**/.git", "dist",
136-
"../tests/tests/**", "www", "**/docs", "../multicast/multicast/**", "*~"
142+
"*~",
143+
"www",
144+
"dist",
145+
"_build",
146+
".github",
147+
"**/docs",
148+
"**/.git",
149+
".DS_Store",
150+
".circleci",
151+
"codecov_env",
152+
"../tests/tests/**",
153+
"../multicast/multicast/**",
137154
]
138155

139156
# The reST default role (used for this markup: `text`) to use for all documents.
@@ -161,7 +178,6 @@
161178
# pygments_style_dark ="monokai"
162179
pygments_style_dark = "github-dark"
163180

164-
165181
pygments_options = {
166182
"""tabsize""": 4,
167183
"""stripall""": False,
@@ -268,12 +284,11 @@
268284
# html_use_opensearch = ''
269285

270286
# This is the file name suffix for HTML files (e.g. ".xhtml").
271-
# html_file_suffix = "html"
287+
html_file_suffix = ".html"
272288

273289
# Output file base name for HTML help builder.
274290
htmlhelp_basename = "multicast_doc"
275291

276-
277292
# -- Options for MyST markdown parser -------------------------------------------
278293
# see https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html
279294

@@ -340,13 +355,7 @@
340355
# Grouping the document tree into LaTeX files. List of tuples
341356
# (source start file, target name, title, author, documentclass [howto/manual]).
342357
latex_documents = [
343-
(
344-
"index",
345-
"Documentation.tex",
346-
"Multicast Documentation",
347-
"reactive-firewall",
348-
"manual"
349-
),
358+
("index", "Documentation.tex", "Multicast Documentation", "reactive-firewall", "manual"),
350359
]
351360

352361
# The name of an image file (relative to this directory) to place at the top of
@@ -369,39 +378,29 @@
369378
# If false, no module index is generated.
370379
# latex_domain_indices = True
371380

372-
373381
# -- Options for manual page output --------------------------------------------
374382

375383
# One entry per manual page. List of tuples
376384
# (source start file, name, description, authors, manual section).
377-
man_pages = [
378-
(
379-
"index",
380-
"multicast",
381-
"Multicast Documentation",
382-
["reactive-firewall"],
383-
1
384-
)
385-
]
385+
man_pages = [("index", "multicast", "Multicast Documentation", ["reactive-firewall"], 1)]
386386

387387
# If true, show URL addresses after external links.
388388
# man_show_urls = False
389389

390-
391390
# -- Options for Texinfo output ------------------------------------------------
392391

393392
# Grouping the document tree into Texinfo files. List of tuples
394393
# (source start file, target name, title, author,
395394
# dir menu entry, description, category)
396395
texinfo_documents = [
397396
(
398-
"index",
399-
"Multicast",
400-
"Multicast Documentation",
401-
"reactive-firewall",
402-
"Multicast",
403-
"Multicast Python Module.",
404-
"Miscellaneous"
397+
"index",
398+
"Multicast",
399+
"Multicast Documentation",
400+
"reactive-firewall",
401+
"Multicast",
402+
"Multicast Python Module.",
403+
"Miscellaneous"
405404
),
406405
]
407406

@@ -418,22 +417,19 @@
418417

419418
linkcode_url_prefix: str = f"https://github.com/reactive-firewall/{project}"
420419

420+
suffix = """/issues/%s"""
421+
421422
extlinks = {
422423
"""issue""": (
423-
str("""{prefix}/{suffix}""").format(
424-
prefix=linkcode_url_prefix, suffix="""/issues/%s"""
425-
),
426-
"""issue #%s"""
424+
f"{linkcode_url_prefix}/{suffix}",
425+
"""issue #%s"""
427426
)
428427
}
429428

430429
# try to link with official python3 documentation.
431430
# see https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html for more
432431
intersphinx_mapping = {
433-
"""python""": (
434-
"""https://docs.python.org/3""",
435-
(None, """python-inv.txt""")
436-
)
432+
"""python""": ("""https://docs.python.org/3""", (None, """python-inv.txt"""))
437433
}
438434

439435

docs/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import re
2020

21+
2122
def _validate_git_ref(ref: str) -> str:
2223
"""
2324
Validate if the provided string is a valid Git reference.
@@ -104,6 +105,6 @@ def slugify_header(s: str) -> str:
104105
'cep-7-documentation-guide'
105106
"""
106107
# First, remove special characters and convert to lowercase
107-
text = re.sub(r'[^\w\- ]', '', s).strip().lower()
108+
text = re.sub(r'[^\w\- ]', "", s).strip().lower()
108109
# Then replace consecutive spaces or dashes with a single dash
109-
return re.sub(r'[-\s]+', '-', text)
110+
return re.sub(r'[-\s]+', "-", text)

0 commit comments

Comments
 (0)