Skip to content

Commit

Permalink
Run black on top-level files and /doc (#1361)
Browse files Browse the repository at this point in the history
Co-authored-by: jan iversen <jancasacondor@gmail.com>
  • Loading branch information
alexrudd2 and janiversen authored Feb 19, 2023
1 parent 53aa1ca commit e9d63a4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 34 deletions.
14 changes: 5 additions & 9 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,10 @@
github_doc_root = "https://github.com/pymodbus-dev/pymodbus/tree/master/doc/"

# -- General configuration ------------------------------------------------
extensions = [
'sphinx.ext.autodoc',
'sphinx_rtd_theme',
'sphinx.ext.autosectionlabel'
]
source_suffix = ['.rst']
master_doc = 'index'
project = 'PyModbus'
extensions = ["sphinx.ext.autodoc", "sphinx_rtd_theme", "sphinx.ext.autosectionlabel"]
source_suffix = [".rst"]
master_doc = "index"
project = "PyModbus"
copyright = "See license"
author = "Open Source volunteers"
version = __version__
Expand All @@ -39,7 +35,7 @@


# -- Options for HTML output ----------------------------------------------
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"
html_static_path = []
html_sidebars = {
"**": [
Expand Down
16 changes: 8 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@


dependencies = {}
with open('requirements.txt') as reqs:
with open("requirements.txt") as reqs:
option = None
for line in reqs.read().split('\n'):
if line == '':
for line in reqs.read().split("\n"):
if line == "":
option = None
elif line.startswith('# install:'):
option = line.split(':')[1]
elif line.startswith("# install:"):
option = line.split(":")[1]
dependencies[option] = []
elif not line.startswith('#') and option:
elif not line.startswith("#") and option:
dependencies[option].append(line)

install_req = dependencies['required']
del dependencies['required']
install_req = dependencies["required"]
del dependencies["required"]


# --------------------------------------------------------------------------- #
Expand Down
39 changes: 22 additions & 17 deletions setup_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ class BuildApiDocsCommand(Command):

def initialize_options(self):
"""Initialize options setup."""
if not os.path.exists('./build'):
os.mkdir('./build')
if not os.path.exists("./build"):
os.mkdir("./build")

def finalize_options(self):
"""Finalize options teardown."""
Expand All @@ -34,10 +34,10 @@ def finalize_options(self):
def run(self):
"""Run command."""
old_cwd = os.getcwd()
directories = (d for d in os.listdir('./doc/api') if not d.startswith('.'))
directories = (d for d in os.listdir("./doc/api") if not d.startswith("."))
for entry in directories:
os.chdir('./doc/api/%s' % entry)
os.system('python build.py')
os.chdir("./doc/api/%s" % entry)
os.system("python build.py")
os.chdir(old_cwd)


Expand All @@ -46,9 +46,12 @@ class DeepCleanCommand(Command):

description = "clean everything that we don't want"
user_options = []
trash = ['build', 'dist', 'pymodbus.egg-info',
os.path.join(os.path.join('doc', 'sphinx'), 'build'),
]
trash = [
"build",
"dist",
"pymodbus.egg-info",
os.path.join(os.path.join("doc", "sphinx"), "build"),
]

def initialize_options(self):
"""Initialize options setup."""
Expand All @@ -72,9 +75,9 @@ def _delete_trash_dirs(self):
@staticmethod
def _delete_pyc_files():
"""Remove all python cache files."""
for root, dirs, files in os.walk('.'):
for root, dirs, files in os.walk("."):
for file in files:
if file.endswith('.pyc'):
if file.endswith(".pyc"):
os.remove(os.path.join(root, file))


Expand All @@ -86,22 +89,23 @@ class LintCommand(Command):

def initialize_options(self):
"""Initialize options setup."""
if not os.path.exists('./build'):
os.mkdir('./build')
if not os.path.exists("./build"):
os.mkdir("./build")

def finalize_options(self):
pass

def run(self):
"""Run command."""
scanners = [s for s in dir(self) if s.find('__try') >= 0]
scanners = [s for s in dir(self) if s.find("__try") >= 0]
for scanner in scanners:
if getattr(self, scanner)():
break

def _try_pyflakes(self):
try:
from pyflakes.scripts.pyflakes import main

sys.argv = """pyflakes pymodbus""".split()
main()
return True
Expand All @@ -111,6 +115,7 @@ def _try_pyflakes(self):
def _try_pylint(self):
try:
import pylint

sys.argv = """pylint pymodbus/*.py""".split()
pylint.main()
return True
Expand All @@ -124,12 +129,12 @@ def _try_pylint(self):


command_classes = {
'deep_clean': DeepCleanCommand,
'build_apidocs': BuildApiDocsCommand,
'lint': LintCommand,
"deep_clean": DeepCleanCommand,
"build_apidocs": BuildApiDocsCommand,
"lint": LintCommand,
}

# --------------------------------------------------------------------------- #
# Export command list
# --------------------------------------------------------------------------- #
__all__ = ['command_classes']
__all__ = ["command_classes"]

0 comments on commit e9d63a4

Please sign in to comment.