fortitude-lint 0.7.5__py3-none-win32.whl → 0.8.0rc1__py3-none-win32.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fortitude/__main__.py +77 -16
- {fortitude_lint-0.7.5.data → fortitude_lint-0.8.0rc1.data}/scripts/fortitude.exe +0 -0
- {fortitude_lint-0.7.5.dist-info → fortitude_lint-0.8.0rc1.dist-info}/METADATA +68 -22
- fortitude_lint-0.8.0rc1.dist-info/RECORD +7 -0
- {fortitude_lint-0.7.5.dist-info → fortitude_lint-0.8.0rc1.dist-info}/WHEEL +1 -1
- fortitude_lint-0.7.5.dist-info/RECORD +0 -7
- {fortitude_lint-0.7.5.dist-info → fortitude_lint-0.8.0rc1.dist-info}/licenses/LICENSE +0 -0
fortitude/__main__.py
CHANGED
|
@@ -3,30 +3,91 @@
|
|
|
3
3
|
Adapted from the ``ruff`` launcher script.
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import os
|
|
7
9
|
import sys
|
|
8
10
|
import sysconfig
|
|
9
|
-
from pathlib import Path
|
|
10
11
|
|
|
11
12
|
|
|
12
|
-
def
|
|
13
|
-
"""Return the
|
|
13
|
+
def find_fortitude_bin() -> str:
|
|
14
|
+
"""Return the fortitude binary path."""
|
|
15
|
+
|
|
16
|
+
fortitude_exe = "fortitude" + sysconfig.get_config_var("EXE")
|
|
17
|
+
|
|
18
|
+
scripts_path = os.path.join(sysconfig.get_path("scripts"), fortitude_exe)
|
|
19
|
+
if os.path.isfile(scripts_path):
|
|
20
|
+
return scripts_path
|
|
21
|
+
|
|
22
|
+
if sys.version_info >= (3, 10):
|
|
23
|
+
user_scheme = sysconfig.get_preferred_scheme("user")
|
|
24
|
+
elif os.name == "nt":
|
|
25
|
+
user_scheme = "nt_user"
|
|
26
|
+
elif sys.platform == "darwin" and sys._framework:
|
|
27
|
+
user_scheme = "osx_framework_user"
|
|
28
|
+
else:
|
|
29
|
+
user_scheme = "posix_user"
|
|
30
|
+
|
|
31
|
+
user_path = os.path.join(
|
|
32
|
+
sysconfig.get_path("scripts", scheme=user_scheme), fortitude_exe
|
|
33
|
+
)
|
|
34
|
+
if os.path.isfile(user_path):
|
|
35
|
+
return user_path
|
|
14
36
|
|
|
15
|
-
|
|
37
|
+
# Search in `bin` adjacent to package root (as created by `pip install --target`).
|
|
38
|
+
pkg_root = os.path.dirname(os.path.dirname(__file__))
|
|
39
|
+
target_path = os.path.join(pkg_root, "bin", fortitude_exe)
|
|
40
|
+
if os.path.isfile(target_path):
|
|
41
|
+
return target_path
|
|
16
42
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
43
|
+
# Search for pip-specific build environments.
|
|
44
|
+
#
|
|
45
|
+
# Expect to find fortitude in <prefix>/pip-build-env-<rand>/overlay/bin/fortitude
|
|
46
|
+
# Expect to find a "normal" folder at <prefix>/pip-build-env-<rand>/normal
|
|
47
|
+
#
|
|
48
|
+
# See: https://github.com/pypa/pip/blob/102d8187a1f5a4cd5de7a549fd8a9af34e89a54f/src/pip/_internal/build_env.py#L87
|
|
49
|
+
paths = os.environ.get("PATH", "").split(os.pathsep)
|
|
50
|
+
if len(paths) >= 2:
|
|
20
51
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return exe
|
|
52
|
+
def get_last_three_path_parts(path: str) -> list[str]:
|
|
53
|
+
"""Return a list of up to the last three parts of a path."""
|
|
54
|
+
parts = []
|
|
25
55
|
|
|
26
|
-
|
|
27
|
-
|
|
56
|
+
while len(parts) < 3:
|
|
57
|
+
head, tail = os.path.split(path)
|
|
58
|
+
if tail or head != path:
|
|
59
|
+
parts.append(tail)
|
|
60
|
+
path = head
|
|
61
|
+
else:
|
|
62
|
+
parts.append(path)
|
|
63
|
+
break
|
|
64
|
+
|
|
65
|
+
return parts
|
|
66
|
+
|
|
67
|
+
maybe_overlay = get_last_three_path_parts(paths[0])
|
|
68
|
+
maybe_normal = get_last_three_path_parts(paths[1])
|
|
69
|
+
if (
|
|
70
|
+
len(maybe_normal) >= 3
|
|
71
|
+
and maybe_normal[-1].startswith("pip-build-env-")
|
|
72
|
+
and maybe_normal[-2] == "normal"
|
|
73
|
+
and len(maybe_overlay) >= 3
|
|
74
|
+
and maybe_overlay[-1].startswith("pip-build-env-")
|
|
75
|
+
and maybe_overlay[-2] == "overlay"
|
|
76
|
+
):
|
|
77
|
+
# The overlay must contain the fortitude binary.
|
|
78
|
+
candidate = os.path.join(paths[0], fortitude_exe)
|
|
79
|
+
if os.path.isfile(candidate):
|
|
80
|
+
return candidate
|
|
81
|
+
|
|
82
|
+
raise FileNotFoundError(scripts_path)
|
|
28
83
|
|
|
29
84
|
|
|
30
85
|
if __name__ == "__main__":
|
|
31
|
-
|
|
32
|
-
sys.
|
|
86
|
+
fortitude = find_fortitude_bin()
|
|
87
|
+
if sys.platform == "win32":
|
|
88
|
+
import subprocess
|
|
89
|
+
|
|
90
|
+
completed_process = subprocess.run([fortitude, *sys.argv[1:]])
|
|
91
|
+
sys.exit(completed_process.returncode)
|
|
92
|
+
else:
|
|
93
|
+
os.execvp(fortitude, [fortitude, *sys.argv[1:]])
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fortitude-lint
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.0rc1
|
|
4
4
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
5
5
|
Classifier: Intended Audience :: Developers
|
|
6
6
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -14,11 +14,12 @@ Provides-Extra: lint
|
|
|
14
14
|
License-File: LICENSE
|
|
15
15
|
Summary: A Fortran linter, written in Rust and installable with Python
|
|
16
16
|
Keywords: Fortran,linter
|
|
17
|
-
Author-email: Liam Pattinson <liampattinson@gmail.com>, Peter Hill <peter.hill@york.ac.uk>
|
|
18
|
-
Requires-Python: >=3.
|
|
17
|
+
Author-email: Liam Pattinson <liampattinson@gmail.com>, Peter Hill <peter.hill@york.ac.uk>, Ian McInerney <i.mcinerney17@imperial.ac.uk>
|
|
18
|
+
Requires-Python: >=3.7
|
|
19
19
|
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
20
20
|
Project-URL: Repository, https://github.com/PlasmaFAIR/fortitude
|
|
21
21
|
|
|
22
|
+
[](https://github.com/PlasmaFAIR/fortitude)
|
|
22
23
|
[](https://pypi.org/project/fortitude-lint)
|
|
23
24
|
[](https://github.com/PlasmaFAIR/fortitude/blob/main/LICENSE)
|
|
24
25
|

|
|
@@ -30,18 +31,38 @@ Project-URL: Repository, https://github.com/PlasmaFAIR/fortitude
|
|
|
30
31
|
A Fortran linter, inspired by (and built upon) [Ruff](https://github.com/astral-sh/ruff).
|
|
31
32
|
Written in Rust :crab: and installable with Python :snake:.
|
|
32
33
|
|
|
34
|
+
<p align="center">
|
|
35
|
+
<picture align="center">
|
|
36
|
+
<source media="(prefers-color-scheme: dark)" srcset="docs/assets/performance_plot_dark.svg">
|
|
37
|
+
<source media="(prefers-color-scheme: light)" srcset="docs/assets/performance_plot_light.svg">
|
|
38
|
+
<img alt="Shows a bar chart with benchmark results." src="docs/assets/performance_plot_light.svg">
|
|
39
|
+
</picture>
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
<p align="center">
|
|
43
|
+
<i>Linting 43 files from the GS2 repo.</i>
|
|
44
|
+
</p>
|
|
45
|
+
|
|
33
46
|
- :zap: Blazingly fast, up to hundreds of times faster than other open-source Fortran
|
|
34
47
|
linters.
|
|
35
48
|
- :wrench: Automatically fixes linter warnings.
|
|
36
|
-
- :chart_with_upwards_trend:
|
|
49
|
+
- :chart_with_upwards_trend: Almost 100 rules, with many more planned.
|
|
37
50
|
- :page_with_curl: Multiple output formats, including SARIF and GitHub/GitLab CI.
|
|
38
51
|
- :handshake: Follows [community best
|
|
39
52
|
practices](https://fortran-lang.org/learn/best_practices/).
|
|
40
53
|
- :muscle: Built on a robust [tree-sitter](https://tree-sitter.github.io/tree-sitter/)
|
|
41
54
|
parser.
|
|
42
55
|
|
|
56
|
+
Fortitude is developed by
|
|
57
|
+
[PlasmaFAIR](https://plasmafair.readthedocs.io), improving the
|
|
58
|
+
sustainability of plasma science research software.
|
|
59
|
+
|
|
60
|
+

|
|
61
|
+
|
|
43
62
|
## Table of Contents
|
|
44
63
|
|
|
64
|
+
For more detail, please see our [documentation](https://fortitude.readthedocs.io).
|
|
65
|
+
|
|
45
66
|
- [Installation](#installation)
|
|
46
67
|
- [Usage](#usage)
|
|
47
68
|
- [Contributing](#contributing)
|
|
@@ -76,7 +97,7 @@ It can also be installed as a pure Rust project:
|
|
|
76
97
|
```bash
|
|
77
98
|
git clone https://github.com/PlasmaFAIR/fortitude
|
|
78
99
|
cd fortitude
|
|
79
|
-
cargo install --path fortitude
|
|
100
|
+
cargo install --path crates/fortitude
|
|
80
101
|
```
|
|
81
102
|
|
|
82
103
|
Fortitude can also be installed via [other package managers](https://fortitude.readthedocs.io/en/stable/installation/)
|
|
@@ -100,11 +121,11 @@ fortitude check --file-extensions=f90,fpp
|
|
|
100
121
|
|
|
101
122
|
Be default, Fortitude will ignore files and directories in your `.gitignore`.
|
|
102
123
|
This can be disabled by setting `--no-respect-gitignore`. Additional excludes
|
|
103
|
-
can be set using `--
|
|
124
|
+
can be set using `--extend-exclude`:
|
|
104
125
|
|
|
105
126
|
```bash
|
|
106
127
|
# Don't check in the `benchmarks/` and `tests/` directories.
|
|
107
|
-
fortitude check --exclude=benchmarks,tests
|
|
128
|
+
fortitude check --extend-exclude=benchmarks,tests
|
|
108
129
|
```
|
|
109
130
|
|
|
110
131
|
You can select or ignore individual rules or whole groups with
|
|
@@ -146,6 +167,15 @@ fortitude explain S
|
|
|
146
167
|
fortitude explain obsolescent superfluous-implicit-none
|
|
147
168
|
```
|
|
148
169
|
|
|
170
|
+
Use `--summary` to get a brief overview:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Overview of all rules
|
|
174
|
+
fortitude explain --summary
|
|
175
|
+
# Overview of all style rules
|
|
176
|
+
fortitude explain style --summary
|
|
177
|
+
```
|
|
178
|
+
|
|
149
179
|
To see further commands and optional arguments, try using `--help`:
|
|
150
180
|
|
|
151
181
|
```bash
|
|
@@ -155,9 +185,6 @@ fortitude check --help
|
|
|
155
185
|
|
|
156
186
|
### Fixes
|
|
157
187
|
|
|
158
|
-
> [!NOTE]
|
|
159
|
-
> Added in v0.6.0
|
|
160
|
-
|
|
161
188
|
Fortitude can automatically fix some lint warnings, such as
|
|
162
189
|
unnecessary `implicit none` statements, missing double-colons in
|
|
163
190
|
variable declarations, and more. Just pass the `--fix` flag to
|
|
@@ -173,9 +200,6 @@ Run `fortitude explain` to see which rules have fixes available.
|
|
|
173
200
|
|
|
174
201
|
### Preview
|
|
175
202
|
|
|
176
|
-
> [!NOTE]
|
|
177
|
-
> Added in v0.6.0
|
|
178
|
-
|
|
179
203
|
Some fortitude rules are only available through an opt-in preview
|
|
180
204
|
mode to give the community some time to evaluate them and provide
|
|
181
205
|
feedback. To enable preview rules, pass the `--preview` flag to
|
|
@@ -201,12 +225,11 @@ preview = true
|
|
|
201
225
|
|
|
202
226
|
Run `fortitude explain` to see which rules are in preview mode.
|
|
203
227
|
|
|
204
|
-
|
|
205
|
-
|
|
206
228
|
## Configuration
|
|
207
229
|
|
|
208
|
-
Fortitude will look for either a `fortitude.toml` or `fpm.toml`
|
|
209
|
-
current directory, or one of its parents.
|
|
230
|
+
Fortitude will look for either a `fortitude.toml`, `.fortitude.toml` or `fpm.toml`
|
|
231
|
+
file in the current directory, or one of its parents.
|
|
232
|
+
If using `fortitude.toml` or `.fortitude.toml`, settings
|
|
210
233
|
should be under the command name:
|
|
211
234
|
|
|
212
235
|
```toml
|
|
@@ -234,6 +257,30 @@ rules on top of those in the configuration file.
|
|
|
234
257
|
fortitude check --extend-select=OB
|
|
235
258
|
```
|
|
236
259
|
|
|
260
|
+
A description of configuration options can be viewed using the `config`
|
|
261
|
+
command:
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
# View all options under the 'check' heading
|
|
265
|
+
fortitude config check
|
|
266
|
+
# Get description of the 'extend-select' option
|
|
267
|
+
fortitude config check.extend-select
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Editor Integration
|
|
271
|
+
|
|
272
|
+
> [!NOTE]
|
|
273
|
+
> Added in v0.8.0
|
|
274
|
+
|
|
275
|
+
Fortitude can be integrated into text editors and IDEs that support the
|
|
276
|
+
Language Server Protocol (LSP), providing real-time diagnostics and
|
|
277
|
+
code actions for applying fixes as you work.
|
|
278
|
+
|
|
279
|
+
Please see the [documentation](fortitude.readthedocs.io/en/stable/editors) for
|
|
280
|
+
details on setting this up for your editor.
|
|
281
|
+
|
|
282
|
+
A VSCode plugin is in development, and will be released shortly.
|
|
283
|
+
|
|
237
284
|
## pre-commit
|
|
238
285
|
|
|
239
286
|
[Pre-commit](https://pre-commit.com/) hooks for Fortitude are available
|
|
@@ -245,11 +292,10 @@ See [table of rules](https://fortitude.readthedocs.io/en/stable/rules/) for a li
|
|
|
245
292
|
|
|
246
293
|
## Contributing
|
|
247
294
|
|
|
248
|
-
Please feel free to add or suggest new rules
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
running tests, and linting/formatting the code. Please consult our [code of
|
|
295
|
+
Please feel free to add or suggest new rules and features! See
|
|
296
|
+
[`CONTRIBUTING.md`](CONTRIBUTING.md) for a guide on contributing to the project.
|
|
297
|
+
This also includes instructions for building the project from source, running
|
|
298
|
+
tests, and linting/formatting the code. Please consult our [code of
|
|
253
299
|
conduct](CODE_OF_CONDUCT.md) before contributing.
|
|
254
300
|
|
|
255
301
|
## License
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
fortitude/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
fortitude/__main__.py,sha256=YRdc0JUPzp91_gmOUIaJqAmDRg4td4P30ZY6_Pqu67I,3162
|
|
3
|
+
fortitude_lint-0.8.0rc1.data/scripts/fortitude.exe,sha256=5juY92cbYp4IhRc5_buGzE4-qk5yP8jihgLY3JQfm-Y,14517760
|
|
4
|
+
fortitude_lint-0.8.0rc1.dist-info/METADATA,sha256=azReSMUDjBU0oVe6RRpPiiLoUoGTNNMqCZ3_KIZw1lk,9780
|
|
5
|
+
fortitude_lint-0.8.0rc1.dist-info/WHEEL,sha256=WDMAB4uGoBTLFFNNHYBIIVDGp2BkavHkkLG_raftdhA,90
|
|
6
|
+
fortitude_lint-0.8.0rc1.dist-info/licenses/LICENSE,sha256=1kdFuOEkOoA_aOl6qzkTs8JdsW5k5ngnYOqqzsduqbg,2319
|
|
7
|
+
fortitude_lint-0.8.0rc1.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
fortitude/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
fortitude/__main__.py,sha256=3PqWgiZHqg8yC1Q88UazUmufNvBqSdMdDKh6067ryEc,889
|
|
3
|
-
fortitude_lint-0.7.5.data/scripts/fortitude.exe,sha256=FINY1MljybtBNIV39h1omuMQIExDtH_D8lN6DbqTXvw,11827200
|
|
4
|
-
fortitude_lint-0.7.5.dist-info/METADATA,sha256=TpBp53viFVKzDwALSG4SpPDgcPQD2TMaFbFRE3_fmxI,8035
|
|
5
|
-
fortitude_lint-0.7.5.dist-info/WHEEL,sha256=Q4EuPurnoomImVpjwa0YbplsthbqY-uCz1VRFQ9bQ98,89
|
|
6
|
-
fortitude_lint-0.7.5.dist-info/licenses/LICENSE,sha256=1kdFuOEkOoA_aOl6qzkTs8JdsW5k5ngnYOqqzsduqbg,2319
|
|
7
|
-
fortitude_lint-0.7.5.dist-info/RECORD,,
|
|
File without changes
|