Skip to content

Commit

Permalink
Added Ruff config.
Browse files Browse the repository at this point in the history
  • Loading branch information
tdulcet committed Oct 20, 2024
1 parent f944319 commit b75067b
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
set -x
bash -e -o pipefail -- mlucas.sh ANONYMOUS
echo -e '## Warnings\n```' >> $GITHUB_STEP_SUMMARY
grep 'warning:' Mlucas/obj/build.log | sed 's/\x1B\[\([0-9]\+\(;[0-9]\+\)*\)\?m//g' | awk '{ print $NF }' | sort | uniq -c | sort -nr >> $GITHUB_STEP_SUMMARY
grep 'warning:' Mlucas/obj/build.log | sed 's/\x1B\[\([0-9]\+\(;[0-9]\+\)*\)\?[mK]//g' | awk '{ print $NF }' | sort | uniq -c | sort -nr >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
- uses: actions/upload-artifact@v4
if: always()
Expand Down Expand Up @@ -141,5 +141,5 @@ jobs:
python3 -m pip install --upgrade pip
python3 -m pip install ruff
- name: Script
run: ruff check --output-format=github --target-version py37 --select F,E4,E7,E9,W,I,D,UP,YTT,S,BLE,B,A,COM819,C4,T10,EM,EXE,ISC,ICN,G,PIE,PYI,Q,RSE,RET,SLF,SLOT,SIM,TID,TCH,ARG,PGH,PL,TRY,PERF,FURB,LOG,RUF --preview --ignore W191,D211,D213,D401,UP004,UP008,UP009,UP010,UP024,UP030,UP032,UP036,PYI024,PLR09,PLR1702,PLR2004,S324,S404,S603,FURB101,FURB167,RUF001,RUF002,RUF003,RUF005,RUF023 .
run: ruff check --output-format=github .
continue-on-error: true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Pull requests welcome! Ideas for contributions:
* Update install scripts to support CLI options
* Add options for setting the maximum CPU time
* Update CUDALucas to support PRP tests and the Jacobi error check for LL tests
* Update Mlucas to support the Jacobi error check for LL and P-1 tests
* Update Mlucas to support the Jacobi error check for LL and P-1 tests, and proof generation for PRP tests
* Finish and improve the performance of [TensorPrime](https://github.com/TPU-Mersenne-Prime-Search/TensorPrime), the [Tensor Processing Unit](https://en.wikipedia.org/wiki/Tensor_Processing_Unit) (TPU) GIMPS program (see [here](https://github.com/TPU-Mersenne-Prime-Search/TensorPrime/wiki#results-and-next-steps))

Thanks to [Daniel Connelly](https://github.com/Danc2050) for porting the MPrime script to Python and for helping create and test the Google Colab Jupyter Notebooks!
87 changes: 87 additions & 0 deletions google-colab/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
[tool.ruff]
line-length = 132 # 88
indent-width = 2

target-version = "py310"

preview = true

output-format = "concise"

[tool.ruff.lint]
select = [
"F",
"E4",
"E7",
"E9",
"W",
"I",
"D",
"UP",
"YTT",
"S",
"BLE",
"B",
"A",
"COM819",
"C4",
"T10",
"EM",
"EXE",
"ISC",
"ICN",
"G",
"PIE",
"PYI",
"Q",
"RSE",
"RET",
"SLF",
"SLOT",
"SIM",
"TID",
"TCH",
"ARG",
"PGH",
"PL",
"TRY",
"FLY",
"PERF",
"FURB",
"LOG",
"RUF"
]
ignore = [
"W191",
"D211",
"D213",
"D300",
"D401",
"PLR09",
"PLR1702",
"PLR2004",
"S103",
"FURB101",
"FURB167",
"RUF001",
"RUF002",
"RUF003",
"RUF023"
]

unfixable = ["F841"]

[tool.ruff.lint.isort]
split-on-trailing-comma = false

[tool.ruff.lint.flake8-quotes]
docstring-quotes = "single"
inline-quotes = "single"
multiline-quotes = "single"

[tool.ruff.format]
quote-style = "preserve"

indent-style = "space"

skip-magic-trailing-comma = true
6 changes: 3 additions & 3 deletions mprime-python-port/mprime.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ def sha256sum(filename):
import requests
except ImportError:
print(
"""Please run the below command to install the Requests library:
f"""Please run the below command to install the Requests library:
{0} -m pip install requests
{os.path.basename(sys.executable) if sys.executable else "python3"} -m pip install requests
Then, run the script again.""".format(os.path.basename(sys.executable) if sys.executable else "python3")
Then, run the script again."""

Check warning on line 73 in mprime-python-port/mprime.py

View workflow job for this annotation

GitHub Actions / Pylint

W2601

F-strings are not supported by all versions included in the py-version setting

Check warning on line 73 in mprime-python-port/mprime.py

View workflow job for this annotation

GitHub Actions / Pylint

W2601

F-strings are not supported by all versions included in the py-version setting
)
sys.exit(0)
# ----------------------------#
Expand Down
80 changes: 80 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
[tool.ruff]
line-length = 132 # 88
indent-width = 4

target-version = "py37"

preview = true

output-format = "concise"

[tool.ruff.lint]
select = [
"F",
"E4",
"E7",
"E9",
"W",
"I",
# "D",
"UP",
"YTT",
"S",
"BLE",
"B",
"A",
"COM819",
"C4",
"T10",
"EM",
"EXE",
"ISC",
"ICN",
"G",
"PIE",
"PYI",
"Q",
"RSE",
"RET",
"SLF",
"SLOT",
"SIM",
"TID",
"TCH",
"ARG",
"PGH",
"PL",
"TRY",
"FLY",
"PERF",
"FURB",
"LOG",
"RUF"
]
ignore = [
"W191",
"D211",
"D213",
"D401",
"PLR09",
"PLR1702",
"PLR2004",
"S404",
"S603",
"FURB101",
"FURB167",
"RUF001",
"RUF002",
"RUF003",
"RUF023"
]

[tool.ruff.lint.isort]
split-on-trailing-comma = false

[tool.ruff.format]
quote-style = "double"

indent-style = "space" # "tab"

skip-magic-trailing-comma = true

0 comments on commit b75067b

Please sign in to comment.