Skip to content

Commit 653b6cf

Browse files
authored
Enable Code Formatting Checks (#5)
* Enabling code formatting checks, applying yapf * Applying yapf with new space_inside_brackets setting
1 parent 8c38fb7 commit 653b6cf

File tree

92 files changed

+5571
-5577
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+5571
-5577
lines changed

.github/workflows/python-package.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ jobs:
3030
python -m pip install --upgrade pip
3131
python -m pip install pytest yapf toml
3232
python -m pip install .
33-
# - name: Lint with yapf
34-
# working-directory: ./${{ matrix.package-name }}
35-
# run: |
36-
# yapf -r --diff .
33+
- name: Lint with yapf
34+
working-directory: ./${{ matrix.package-name }}
35+
run: |
36+
yapf -r --diff . --style ../.style.yapf
3737
# - name: Test with pytest
3838
# working-directory: ./${{ matrix.package-name }}
3939
# run: |

.style.yapf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[style]
2+
based_on_style = pep8
3+
spaces_before_comment = 2
4+
split_before_logical_operator = true
5+
column_limit = 120
6+
space_inside_brackets = true

docs/conf.py

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,10 @@
1818

1919
# Add python modules to be documented
2020
python_root = '..'
21-
python_modules = ('geosx_mesh_tools_package',
22-
'geosx_xml_tools_package',
23-
'geosx_mesh_doctor',
24-
'geos_ats_package',
25-
'hdf5_wrapper_package',
26-
'pygeosx_tools_package',
27-
'timehistory_package')
21+
python_modules = ( 'geosx_mesh_tools_package', 'geosx_xml_tools_package', 'geosx_mesh_doctor', 'geos_ats_package',
22+
'hdf5_wrapper_package', 'pygeosx_tools_package', 'timehistory_package' )
2823
for m in python_modules:
29-
sys.path.insert(0, os.path.abspath(os.path.join(python_root, m)))
30-
24+
sys.path.insert( 0, os.path.abspath( os.path.join( python_root, m ) ) )
3125

3226
# -- Project information -----------------------------------------------------
3327

@@ -40,7 +34,6 @@
4034
# The full version, including alpha/beta/rc tags
4135
release = u''
4236

43-
4437
# -- General configuration ---------------------------------------------------
4538

4639
# If your documentation needs a minimal Sphinx version, state it here.
@@ -51,18 +44,11 @@
5144
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
5245
# ones.
5346
extensions = [
54-
'sphinx_design',
55-
'sphinx.ext.todo',
56-
'sphinx.ext.autodoc',
57-
'sphinx.ext.doctest',
58-
'sphinx.ext.imgmath',
59-
'sphinxarg.ext',
60-
'sphinx.ext.napoleon',
61-
'sphinxcontrib.programoutput'
47+
'sphinx_design', 'sphinx.ext.todo', 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.imgmath',
48+
'sphinxarg.ext', 'sphinx.ext.napoleon', 'sphinxcontrib.programoutput'
6249
]
6350

64-
65-
autodoc_mock_imports = ["pygeosx", "pylvarray", "meshio", "lxml", "mpi4py", "h5py", "ats", "scipy"]
51+
autodoc_mock_imports = [ "pygeosx", "pylvarray", "meshio", "lxml", "mpi4py", "h5py", "ats", "scipy" ]
6652

6753
# The suffix(es) of source filenames.
6854
# You can specify multiple suffix as a list of string:
@@ -83,34 +69,28 @@
8369
# List of patterns, relative to source directory, that match files and
8470
# directories to ignore when looking for source files.
8571
# This pattern also affects html_static_path and html_extra_path .
86-
exclude_patterns = [u'_build', 'Thumbs.db', '.DS_Store', 'cmake/*']
72+
exclude_patterns = [ u'_build', 'Thumbs.db', '.DS_Store', 'cmake/*' ]
8773

8874
todo_include_todos = True
8975

9076
# The name of the Pygments (syntax highlighting) style to use.
9177
pygments_style = 'sphinx'
9278

93-
9479
# -- Theme options ----------------------------------------------
9580
extensions += [
9681
'sphinx_rtd_theme',
9782
]
9883

9984
html_theme = "sphinx_rtd_theme"
10085

101-
html_theme_options = {
102-
'navigation_depth': -1,
103-
'collapse_navigation': False
104-
}
86+
html_theme_options = { 'navigation_depth': -1, 'collapse_navigation': False }
10587

106-
html_static_path = ['./_static']
88+
html_static_path = [ './_static' ]
10789

10890
html_css_files = [
10991
'theme_overrides.css',
11092
]
11193

112-
11394
# -- Options for HTMLHelp output ---------------------------------------------
11495
# Output file base name for HTML help builder.
11596
htmlhelp_basename = 'geosPythonPackagesDoc'
116-

geos_ats_package/geos_ats/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
# Add the machines module to the ats.atsMachines submodule,
55
# So that ats can find our custom definitions at runtime
6-
sys.modules['ats.atsMachines.machines'] = machines
6+
sys.modules[ 'ats.atsMachines.machines' ] = machines

geos_ats_package/geos_ats/command_line_parsers.py

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -36,49 +36,58 @@
3636

3737

3838
def build_command_line_parser():
39-
parser = argparse.ArgumentParser(description="Runs GEOS integrated tests")
39+
parser = argparse.ArgumentParser( description="Runs GEOS integrated tests" )
4040

41-
parser.add_argument("geos_bin_dir", type=str, help="GEOS binary directory.")
41+
parser.add_argument( "geos_bin_dir", type=str, help="GEOS binary directory." )
4242

43-
parser.add_argument("-w", "--workingDir", type=str, help="Initial working directory")
43+
parser.add_argument( "-w", "--workingDir", type=str, help="Initial working directory" )
4444

45-
action_names = ','.join(action_options.keys())
46-
parser.add_argument("-a", "--action", type=str, default="run", help=f"Test actions options ({action_names})")
45+
action_names = ','.join( action_options.keys() )
46+
parser.add_argument( "-a", "--action", type=str, default="run", help=f"Test actions options ({action_names})" )
4747

48-
check_names = ','.join(check_options.keys())
49-
parser.add_argument("-c", "--check", type=str, default="all", help=f"Test check options ({check_names})")
48+
check_names = ','.join( check_options.keys() )
49+
parser.add_argument( "-c", "--check", type=str, default="all", help=f"Test check options ({check_names})" )
5050

51-
verbosity_names = ','.join(verbose_options.keys())
52-
parser.add_argument("-v", "--verbose", type=str, default="info", help=f"Log verbosity options ({verbosity_names})")
51+
verbosity_names = ','.join( verbose_options.keys() )
52+
parser.add_argument( "-v",
53+
"--verbose",
54+
type=str,
55+
default="info",
56+
help=f"Log verbosity options ({verbosity_names})" )
5357

54-
parser.add_argument("-d", "--detail", action="store_true", default=False, help="Show detailed action/check options")
58+
parser.add_argument( "-d",
59+
"--detail",
60+
action="store_true",
61+
default=False,
62+
help="Show detailed action/check options" )
5563

56-
parser.add_argument("-i", "--info", action="store_true", default=False, help="Info on various topics")
64+
parser.add_argument( "-i", "--info", action="store_true", default=False, help="Info on various topics" )
5765

58-
parser.add_argument("-r",
59-
"--restartCheckOverrides",
60-
nargs='+',
61-
action='append',
62-
help='Restart check parameter override (name value)',
63-
default=[])
66+
parser.add_argument( "-r",
67+
"--restartCheckOverrides",
68+
nargs='+',
69+
action='append',
70+
help='Restart check parameter override (name value)',
71+
default=[] )
6472

65-
parser.add_argument("--salloc",
66-
default=True,
67-
help="Used by the chaosM machine to first allocate nodes with salloc, before running the tests")
73+
parser.add_argument(
74+
"--salloc",
75+
default=True,
76+
help="Used by the chaosM machine to first allocate nodes with salloc, before running the tests" )
6877

6978
parser.add_argument(
7079
"--sallocoptions",
7180
type=str,
7281
default="",
73-
help="Used to override all command-line options for salloc. No other options with be used or added.")
82+
help="Used to override all command-line options for salloc. No other options with be used or added." )
7483

75-
parser.add_argument("--ats", nargs='+', default=[], action="append", help="pass arguments to ats")
84+
parser.add_argument( "--ats", nargs='+', default=[], action="append", help="pass arguments to ats" )
7685

77-
parser.add_argument("--machine", default=None, help="name of the machine")
86+
parser.add_argument( "--machine", default=None, help="name of the machine" )
7887

79-
parser.add_argument("--machine-dir", default=None, help="Search path for machine definitions")
88+
parser.add_argument( "--machine-dir", default=None, help="Search path for machine definitions" )
8089

81-
parser.add_argument("-l", "--logs", type=str, default=None)
90+
parser.add_argument( "-l", "--logs", type=str, default=None )
8291

8392
parser.add_argument(
8493
"--failIfTestsFail",
@@ -87,14 +96,14 @@ def build_command_line_parser():
8796
help="geos_ats normally exits with 0. This will cause it to exit with an error code if there was a failed test."
8897
)
8998

90-
parser.add_argument("-n", "-N", "--numNodes", type=int, default="2")
99+
parser.add_argument( "-n", "-N", "--numNodes", type=int, default="2" )
91100

92-
parser.add_argument("ats_targets", type=str, nargs='*', help="ats files or directories.")
101+
parser.add_argument( "ats_targets", type=str, nargs='*', help="ats files or directories." )
93102

94103
return parser
95104

96105

97-
def parse_command_line_arguments(args):
106+
def parse_command_line_arguments( args ):
98107
parser = build_command_line_parser()
99108
options, unkown_args = parser.parse_known_args()
100109
exit_flag = False
@@ -103,7 +112,7 @@ def parse_command_line_arguments(args):
103112
check = options.check
104113
if check not in check_options:
105114
print(
106-
f"Selected check option ({check}) not recognized. Try running with --help/--details for more information")
115+
f"Selected check option ({check}) not recognized. Try running with --help/--details for more information" )
107116
exit_flag = True
108117

109118
action = options.action
@@ -115,15 +124,15 @@ def parse_command_line_arguments(args):
115124

116125
verbose = options.verbose
117126
if verbose not in verbose_options:
118-
print(f"Selected verbose option ({verbose}) not recognized")
127+
print( f"Selected verbose option ({verbose}) not recognized" )
119128
exit_flag = True
120129

121130
# Print detailed information
122131
if options.detail:
123-
for option_type, details in zip(['action', 'check'], [action_options, check_options]):
124-
print(f'\nAvailable {option_type} options:')
132+
for option_type, details in zip( [ 'action', 'check' ], [ action_options, check_options ] ):
133+
print( f'\nAvailable {option_type} options:' )
125134
for k, v in details.items():
126-
print(f' {k}: {v}')
135+
print( f' {k}: {v}' )
127136
exit_flag = True
128137

129138
if exit_flag:
@@ -132,20 +141,20 @@ def parse_command_line_arguments(args):
132141
return options
133142

134143

135-
def patch_parser(parser):
144+
def patch_parser( parser ):
136145

137-
def add_option_patch(*xargs, **kwargs):
146+
def add_option_patch( *xargs, **kwargs ):
138147
"""
139148
Convert type string to actual type instance
140149
"""
141-
tmp = kwargs.get('type', str)
142-
type_map = {'string': str}
143-
if isinstance(tmp, str):
150+
tmp = kwargs.get( 'type', str )
151+
type_map = { 'string': str }
152+
if isinstance( tmp, str ):
144153
if tmp in type_map:
145-
tmp = type_map[tmp]
154+
tmp = type_map[ tmp ]
146155
else:
147-
tmp = locate(tmp)
148-
kwargs['type'] = tmp
149-
parser.add_argument(*xargs, **kwargs)
156+
tmp = locate( tmp )
157+
kwargs[ 'type' ] = tmp
158+
parser.add_argument( *xargs, **kwargs )
150159

151160
parser.add_option = add_option_patch

0 commit comments

Comments
 (0)