Skip to content

Commit 4fe510a

Browse files
authored
Introduce flake8 style guidelines (#608)
* Add venv and vs code settings to gitignore * Remove blank lines and add trailing lines where needed * Add flake8 config * Add flake8 to style CI * Convert indentation to spaces * Fix underindentation * Convert indentation to spaces
1 parent 4a6c2a1 commit 4fe510a

22 files changed

+38
-53
lines changed

.flake8

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[flake8]
2+
exclude = venv, __init__.py
3+
# To be added after refactoring code to be compliant: E501, F401, W191, W291, W293
4+
select = W391, E115, E117, E122, E124, E125, E225, E231, E301, E303, F403
5+
count = True
6+
max-complexity = 10
7+
max-line-length = 100
8+
statistics = True

.github/workflows/style.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ jobs:
2020
run: |
2121
pip install -r requirements_style.txt --disable-pip-version-check
2222
make
23+
24+
- name: flake8
25+
run: |
26+
make flake8

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,10 @@ docker/mapdl/v212
7575
docker/mapdl/_old
7676

7777
# temp testing
78-
tmp.out
78+
tmp.out
79+
80+
# virtual environment
81+
venv/
82+
83+
# Visual studio code local settings
84+
.vscode/

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ coverage-xml:
3131
coverage-html:
3232
@echo "Reporting HTML coverage"
3333
@pytest -v --cov ansys.mapdl --cov-report html
34+
35+
flake8:
36+
@echo "Running flake8"
37+
@flake8 .

ansys/mapdl/core/inline_functions/nearest_queries.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,3 @@ def enearn(self, n: int) -> int:
113113
response = self._mapdl.run(f'_=ENEARN({n})')
114114
integer = self._parse_parameter_integer_response(response)
115115
return integer
116-

ansys/mapdl/core/inline_functions/normals_queries.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,4 +268,3 @@ def normkz(self, k1: int, k2: int, k3: int) -> float:
268268
response = self._mapdl.run(f'_=NORMKZ({k1}, {k2}, {k3})')
269269
float_ = self._parse_parameter_float_response(response)
270270
return float_
271-

ansys/mapdl/core/launcher.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ def launch_grpc(exec_file='', jobname='file', nproc=2, ram=None,
385385
stdout=subprocess.DEVNULL,
386386
stderr=subprocess.DEVNULL)
387387

388-
389388
# watch for the creation of temporary files at the run_directory.
390389
# This lets us know that the MAPDL process has at least started
391390
sleep_time = 0.1

ansys/mapdl/core/mapdl_geometry.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
- 'U' : Unselect a set from the current set.
1313
"""
1414

15-
FLST_LOOKUP = {'NODE': 1, # node numbers
16-
'ELEM': 2, # element numbers
17-
'KP': 3, # keypoint numbers
18-
'LINE': 4, # line numbers
19-
'AREA': 5, # area numbers
20-
'VOLU': 6, # volume numbers
21-
'TRACE': 7, # trace points
22-
'COORD': 8, # coordinate locations
15+
FLST_LOOKUP = {
16+
'NODE': 1, # node numbers
17+
'ELEM': 2, # element numbers
18+
'KP': 3, # keypoint numbers
19+
'LINE': 4, # line numbers
20+
'AREA': 5, # area numbers
21+
'VOLU': 6, # volume numbers
22+
'TRACE': 7, # trace points
23+
'COORD': 8, # coordinate locations
2324
}
2425

2526
def merge_polydata(items):

ansys/mapdl/core/mapdl_grpc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,8 @@ def _kill(self):
643643
self._exited = True
644644

645645
def _close_process(self):
646-
"""Close all MAPDL processes"""
647-
if self._local:
646+
"""Close all MAPDL processes"""
647+
if self._local:
648648
for pid in self._pids:
649649
try:
650650
os.kill(pid, 9)

ansys/mapdl/core/post.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,8 +1159,6 @@ def plot_nodal_total_eqv_strain(self, show_node_numbering=False, **kwargs):
11591159
return self._plot_point_scalars(scalars,
11601160
show_node_numbering=show_node_numbering,
11611161
**kwargs)
1162-
###############################################################################
1163-
11641162

11651163
def nodal_elastic_component_strain(self, component) -> np.ndarray:
11661164
"""Elastic nodal component strain
@@ -1432,11 +1430,7 @@ def plot_nodal_elastic_eqv_strain(self, show_node_numbering=False, **kwargs):
14321430
return self._plot_point_scalars(scalars,
14331431
show_node_numbering=show_node_numbering,
14341432
**kwargs)
1435-
1436-
1437-
###############################################################################
1438-
1439-
1433+
14401434
def nodal_plastic_component_strain(self, component) -> np.ndarray:
14411435
"""Plastic nodal component strain
14421436
@@ -1707,11 +1701,7 @@ def plot_nodal_plastic_eqv_strain(self, show_node_numbering=False, **kwargs):
17071701
return self._plot_point_scalars(scalars,
17081702
show_node_numbering=show_node_numbering,
17091703
**kwargs)
1710-
1711-
1712-
###############################################################################
1713-
1714-
1704+
17151705
def nodal_thermal_component_strain(self, component) -> np.ndarray:
17161706
"""Thermal nodal component strain
17171707
@@ -1982,4 +1972,3 @@ def plot_nodal_thermal_eqv_strain(self, show_node_numbering=False, **kwargs):
19821972
return self._plot_point_scalars(scalars,
19831973
show_node_numbering=show_node_numbering,
19841974
**kwargs)
1985-

0 commit comments

Comments
 (0)