Skip to content

Commit b15d8d3

Browse files
authored
Apply black formatting (using ruff) and the ruff linter (#256)
* ruff format and linting * Reinstate import * Small fixes * Import fixes * Doc fixes
1 parent 49e604f commit b15d8d3

File tree

184 files changed

+6253
-3171
lines changed

Some content is hidden

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

184 files changed

+6253
-3171
lines changed

.flake8

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/workflows/pythonapp.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,11 @@ jobs:
2828
uses: actions/setup-python@v5
2929
with:
3030
python-version: ${{ matrix.python-version }}
31-
- name: Lint with flake8
31+
- name: Lint with ruff
3232
run: |
33-
python -m pip install flake8
34-
flake8 --statistics .
35-
- name: Check documentation style
36-
run: |
37-
python -m pip install pydocstyle[toml]
38-
python -m pydocstyle ufl/
33+
pip install ruff
34+
ruff check .
35+
ruff format --check .
3936
- name: Install UFL
4037
run: python -m pip install .[ci]
4138
- name: Run unit tests

demo/Constant.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,27 @@
1818
# Modified by Martin Sandve Alnes, 2009
1919
#
2020
# Test form for scalar and vector constants.
21-
from ufl import (Coefficient, Constant, FunctionSpace, Mesh, TestFunction, TrialFunction, VectorConstant, dot, dx, grad,
22-
inner, triangle)
21+
from ufl import (
22+
Coefficient,
23+
Constant,
24+
FunctionSpace,
25+
Mesh,
26+
TestFunction,
27+
TrialFunction,
28+
VectorConstant,
29+
dot,
30+
dx,
31+
grad,
32+
inner,
33+
triangle,
34+
)
2335
from ufl.finiteelement import FiniteElement
2436
from ufl.pullback import identity_pullback
2537
from ufl.sobolevspace import H1
2638

2739
cell = triangle
2840
element = FiniteElement("Lagrange", cell, 1, (), identity_pullback, H1)
29-
domain = Mesh(FiniteElement("Lagrange", cell, 1, (2, ), identity_pullback, H1))
41+
domain = Mesh(FiniteElement("Lagrange", cell, 1, (2,), identity_pullback, H1))
3042
space = FunctionSpace(domain, element)
3143

3244
v = TestFunction(space)

demo/ConvectionJacobi.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,23 @@
22
# Author: Martin Sandve Alnes
33
# Date: 2008-10-03
44
#
5-
from ufl import Coefficient, FunctionSpace, Mesh, TestFunction, TrialFunction, dot, dx, grad, triangle
5+
from ufl import (
6+
Coefficient,
7+
FunctionSpace,
8+
Mesh,
9+
TestFunction,
10+
TrialFunction,
11+
dot,
12+
dx,
13+
grad,
14+
triangle,
15+
)
616
from ufl.finiteelement import FiniteElement
717
from ufl.pullback import identity_pullback
818
from ufl.sobolevspace import H1
919

10-
element = FiniteElement("Lagrange", triangle, 1, (2, ), identity_pullback, H1)
11-
domain = Mesh(FiniteElement("Lagrange", triangle, 1, (2, ), identity_pullback, H1))
20+
element = FiniteElement("Lagrange", triangle, 1, (2,), identity_pullback, H1)
21+
domain = Mesh(FiniteElement("Lagrange", triangle, 1, (2,), identity_pullback, H1))
1222
space = FunctionSpace(domain, element)
1323

1424
u = TrialFunction(space)

demo/ConvectionJacobi2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from ufl.pullback import identity_pullback
88
from ufl.sobolevspace import H1
99

10-
element = FiniteElement("Lagrange", triangle, 1, (2, ), identity_pullback, H1)
11-
domain = Mesh(FiniteElement("Lagrange", triangle, 1, (2, ), identity_pullback, H1))
10+
element = FiniteElement("Lagrange", triangle, 1, (2,), identity_pullback, H1)
11+
domain = Mesh(FiniteElement("Lagrange", triangle, 1, (2,), identity_pullback, H1))
1212
space = FunctionSpace(domain, element)
1313

1414
u = TrialFunction(space)

demo/ConvectionVector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from ufl.pullback import identity_pullback
88
from ufl.sobolevspace import H1
99

10-
element = FiniteElement("Lagrange", triangle, 1, (2, ), identity_pullback, H1)
11-
domain = Mesh(FiniteElement("Lagrange", triangle, 1, (2, ), identity_pullback, H1))
10+
element = FiniteElement("Lagrange", triangle, 1, (2,), identity_pullback, H1)
11+
domain = Mesh(FiniteElement("Lagrange", triangle, 1, (2,), identity_pullback, H1))
1212
space = FunctionSpace(domain, element)
1313

1414
v = TestFunction(space)

demo/Elasticity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
from ufl.pullback import identity_pullback
99
from ufl.sobolevspace import H1
1010

11-
element = FiniteElement("Lagrange", tetrahedron, 1, (3, ), identity_pullback, H1)
12-
domain = Mesh(FiniteElement("Lagrange", tetrahedron, 1, (3, ), identity_pullback, H1))
11+
element = FiniteElement("Lagrange", tetrahedron, 1, (3,), identity_pullback, H1)
12+
domain = Mesh(FiniteElement("Lagrange", tetrahedron, 1, (3,), identity_pullback, H1))
1313
space = FunctionSpace(domain, element)
1414

1515
v = TestFunction(space)

demo/EnergyNorm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from ufl.sobolevspace import H1
2424

2525
element = FiniteElement("Lagrange", tetrahedron, 1, (), identity_pullback, H1)
26-
domain = Mesh(FiniteElement("Lagrange", tetrahedron, 1, (3, ), identity_pullback, H1))
26+
domain = Mesh(FiniteElement("Lagrange", tetrahedron, 1, (3,), identity_pullback, H1))
2727
space = FunctionSpace(domain, element)
2828

2929
v = Coefficient(space)

demo/Equation.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,25 @@
3434
# the unknown u to the right-hand side, all terms may
3535
# be listed on one line and left- and right-hand sides
3636
# extracted by lhs() and rhs().
37-
from ufl import Coefficient, FunctionSpace, Mesh, TestFunction, TrialFunction, dot, dx, grad, lhs, rhs, triangle
37+
from ufl import (
38+
Coefficient,
39+
FunctionSpace,
40+
Mesh,
41+
TestFunction,
42+
TrialFunction,
43+
dot,
44+
dx,
45+
grad,
46+
lhs,
47+
rhs,
48+
triangle,
49+
)
3850
from ufl.finiteelement import FiniteElement
3951
from ufl.pullback import identity_pullback
4052
from ufl.sobolevspace import H1
4153

4254
element = FiniteElement("Lagrange", triangle, 1, (), identity_pullback, H1)
43-
domain = Mesh(FiniteElement("Lagrange", triangle, 1, (2, ), identity_pullback, H1))
55+
domain = Mesh(FiniteElement("Lagrange", triangle, 1, (2,), identity_pullback, H1))
4456
space = FunctionSpace(domain, element)
4557

4658
k = 0.1

demo/ExplicitConvection.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,23 @@
22
# Author: Martin Sandve Alnes
33
# Date: 2008-10-03
44
#
5-
from ufl import Coefficient, FunctionSpace, Mesh, TestFunction, TrialFunction, dot, dx, grad, triangle
5+
from ufl import (
6+
Coefficient,
7+
FunctionSpace,
8+
Mesh,
9+
TestFunction,
10+
TrialFunction,
11+
dot,
12+
dx,
13+
grad,
14+
triangle,
15+
)
616
from ufl.finiteelement import FiniteElement
717
from ufl.pullback import identity_pullback
818
from ufl.sobolevspace import H1
919

10-
element = FiniteElement("Lagrange", triangle, 1, (2, ), identity_pullback, H1)
11-
domain = Mesh(FiniteElement("Lagrange", triangle, 1, (2, ), identity_pullback, H1))
20+
element = FiniteElement("Lagrange", triangle, 1, (2,), identity_pullback, H1)
21+
domain = Mesh(FiniteElement("Lagrange", triangle, 1, (2,), identity_pullback, H1))
1222
space = FunctionSpace(domain, element)
1323

1424
u = TrialFunction(space)

0 commit comments

Comments
 (0)