Repository: mhostetter/galois (language: python)

Issue:
Add `.pre-commit`



Discussion / hints:

Fix patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 000000000..e6720e7b1
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,14 @@
+repos:
+- repo: https://github.com/pre-commit/pre-commit-hooks
+  rev: v2.3.0
+  hooks:
+  - id: check-added-large-files
+  - id: check-yaml
+  - id: check-toml
+  - id: end-of-file-fixer
+  - id: trailing-whitespace
+- repo: https://github.com/astral-sh/ruff-pre-commit
+  rev: v0.1.4
+  hooks:
+  - id: ruff
+  - id: ruff-format
diff --git a/.vscode/settings.json b/.vscode/settings.json
index a34d2cc39..f8611a6fa 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -17,4 +17,4 @@
     "editor.rulers": [
         120
     ],
-}
\ No newline at end of file
+}
diff --git a/README.md b/README.md
index 92d6b8101..962d07218 100644
--- a/README.md
+++ b/README.md
@@ -165,7 +165,7 @@ In [12]: x
 Out[12]: GF([236,  87,  38, 112], order=3^5)
 
 In [13]: GF.repr("poly"); x
-Out[13]: 
+Out[13]:
 GF([2α^4 + 2α^3 + 2α^2 + 2,               α^4 + 2α,
              α^3 + α^2 + 2,      α^4 + α^3 + α + 1], order=3^5)
 
diff --git a/docs/_templates/base.html b/docs/_templates/base.html
index 0985eb37e..085fd392e 100644
--- a/docs/_templates/base.html
+++ b/docs/_templates/base.html
@@ -14,4 +14,4 @@
 <a href="{{ '../' ~ base_url}}">
   <strong>Click here to go to latest.</strong>
 </a>
-{% endblock %}
\ No newline at end of file
+{% endblock %}
diff --git a/docs/release-notes/v0.2.md b/docs/release-notes/v0.2.md
index 80eff1b3d..b186925a5 100644
--- a/docs/release-notes/v0.2.md
+++ b/docs/release-notes/v0.2.md
@@ -27,7 +27,7 @@ tocdepth: 2
     >>> for d in range(3, 10):
     ...     bch = galois.BCH(5**2 - 1, d=d, field=GF)
     ...     print(repr(bch))
-    ... 
+    ...
     <BCH Code: [24, 20, 3] over GF(5)>
     <BCH Code: [24, 18, 4] over GF(5)>
     <BCH Code: [24, 16, 5] over GF(5)>
diff --git a/docs/release-notes/v0.3.md b/docs/release-notes/v0.3.md
index c1f9c93da..a1e64c2c7 100644
--- a/docs/release-notes/v0.3.md
+++ b/docs/release-notes/v0.3.md
@@ -110,11 +110,11 @@ tocdepth: 2
   This speeds up the creation of large finite fields. ([#452](https://github.com/mhostetter/galois/pull/452))
   ```ipython
   In [1]: import galois
-  
+
   # v0.3.1
   In [2]: %time galois.factors(2**256 - 1)
   # Took forever...
-  
+
   # v0.3.2
   In [2]: %time galois.factors(2**256 - 1)
   Wall time: 1 ms
@@ -135,12 +135,12 @@ tocdepth: 2
 - Added speed-up when factoring powers of small primes. This speeds up the creation of large finite fields. ([#454](https://github.com/mhostetter/galois/pull/454))
   ```ipython
   In [1]: import galois
-  
+
   # v0.3.1
   In [2]: %time galois.factors(2**471)
   Wall time: 4.18 s
   Out[2]: ([2], [471])
-  
+
   # v0.3.2
   In [2]: %time galois.factors(2**471)
   Wall time: 2 ms
@@ -177,13 +177,13 @@ tocdepth: 2
   `irreducible_poly()` when `terms="min"` and `method="min"`. ([#462](https://github.com/mhostetter/galois/pull/462))
   ```ipython
   In [1]: import galois
-  
+
   # Manual search
   In [2]: %time galois.irreducible_poly(2, 1001)
   CPU times: user 6.8 s, sys: 0 ns, total: 6.8 s
   Wall time: 6.81 s
   Out[2]: Poly(x^1001 + x^5 + x^3 + x + 1, GF(2))
-  
+
   # With the database
   In [3]: %time galois.irreducible_poly(2, 1001, terms="min")
   CPU times: user 745 µs, sys: 0 ns, total: 745 µs
@@ -194,15 +194,15 @@ tocdepth: 2
   calculations for a given polynomial is only incurred once. ([#470](https://github.com/mhostetter/galois/pull/470))
   ```ipython
   In [1]: import galois
-  
+
   In [2]: f = galois.Poly.Str("x^1001 + x^17 + 1"); f
   Out[2]: Poly(x^1001 + x^17 + 1, GF(2))
-  
+
   In [3]: %time f.is_irreducible()
   CPU times: user 1.05 s, sys: 3.47 ms, total: 1.05 s
   Wall time: 1.06 s
   Out[3]: True
-  
+
   In [4]: %time f.is_irreducible()
   CPU times: user 57 µs, sys: 30 µs, total: 87 µs
   Wall time: 68.2 µs
diff --git a/pyproject.toml b/pyproject.toml
index 86073776a..17d42c9c1 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -57,7 +57,7 @@ dynamic = ["version"]
 
 [project.optional-dependencies]
 dev = [
-    "ruff >= 0.1.0",
+    "ruff == 0.1.4",
     "pytest",
     "pytest-cov[toml]",
     "pytest-xdist",


Test patch:
diff --git a/tests/fields/data/GF(109987^4)/properties.json b/tests/fields/data/GF(109987^4)/properties.json
index f0bb508a5..5afff3143 100644
--- a/tests/fields/data/GF(109987^4)/properties.json
+++ b/tests/fields/data/GF(109987^4)/properties.json
@@ -10,4 +10,4 @@
         100525,
         3
     ]
-}
\ No newline at end of file
+}
diff --git a/tests/fields/data/GF(2)/properties.json b/tests/fields/data/GF(2)/properties.json
index 5ab0a1019..cc5dacf68 100644
--- a/tests/fields/data/GF(2)/properties.json
+++ b/tests/fields/data/GF(2)/properties.json
@@ -7,4 +7,4 @@
         1,
         1
     ]
-}
\ No newline at end of file
+}
diff --git a/tests/fields/data/GF(2147483647)/properties.json b/tests/fields/data/GF(2147483647)/properties.json
index 481d707e2..28d05b55b 100644
--- a/tests/fields/data/GF(2147483647)/properties.json
+++ b/tests/fields/data/GF(2147483647)/properties.json
@@ -7,4 +7,4 @@
         1,
         2147483640
     ]
-}
\ No newline at end of file
+}
diff --git a/tests/fields/data/GF(2^100)/properties.json b/tests/fields/data/GF(2^100)/properties.json
index b5bb61e6a..8cd9775a2 100644
--- a/tests/fields/data/GF(2^100)/properties.json
+++ b/tests/fields/data/GF(2^100)/properties.json
@@ -106,4 +106,4 @@
         0,
         1
     ]
-}
\ No newline at end of file
+}
diff --git a/tests/fields/data/GF(2^2)/properties.json b/tests/fields/data/GF(2^2)/properties.json
index 26bf4a337..a5720231c 100644
--- a/tests/fields/data/GF(2^2)/properties.json
+++ b/tests/fields/data/GF(2^2)/properties.json
@@ -8,4 +8,4 @@
         1,
         1
     ]
-}
\ No newline at end of file
+}
diff --git a/tests/fields/data/GF(2^3)/properties.json b/tests/fields/data/GF(2^3)/properties.json
index e9ff927ba..f5d74240e 100644
--- a/tests/fields/data/GF(2^3)/properties.json
+++ b/tests/fields/data/GF(2^3)/properties.json
@@ -9,4 +9,4 @@
         1,
         1
     ]
-}
\ No newline at end of file
+}
diff --git a/tests/fields/data/GF(2^32)/properties.json b/tests/fields/data/GF(2^32)/properties.json
index eb00d9c13..a3c989cfb 100644
--- a/tests/fields/data/GF(2^32)/properties.json
+++ b/tests/fields/data/GF(2^32)/properties.json
@@ -38,4 +38,4 @@
         0,
         1
     ]
-}
\ No newline at end of file
+}
diff --git a/tests/fields/data/GF(2^8)/properties.json b/tests/fields/data/GF(2^8)/properties.json
index 2d6982b36..6e1f00af7 100644
--- a/tests/fields/data/GF(2^8)/properties.json
+++ b/tests/fields/data/GF(2^8)/properties.json
@@ -14,4 +14,4 @@
         0,
         1
     ]
-}
\ No newline at end of file
+}
diff --git a/tests/fields/data/GF(2^8, 283, 19)/properties.json b/tests/fields/data/GF(2^8, 283, 19)/properties.json
index 220b15e2e..0751e3745 100644
--- a/tests/fields/data/GF(2^8, 283, 19)/properties.json
+++ b/tests/fields/data/GF(2^8, 283, 19)/properties.json
@@ -14,4 +14,4 @@
         1,
         1
     ]
-}
\ No newline at end of file
+}
diff --git a/tests/fields/data/GF(31)/properties.json b/tests/fields/data/GF(31)/properties.json
index 978d4b90a..8b7f48be1 100644
--- a/tests/fields/data/GF(31)/properties.json
+++ b/tests/fields/data/GF(31)/properties.json
@@ -7,4 +7,4 @@
         1,
         28
     ]
-}
\ No newline at end of file
+}
diff --git a/tests/fields/data/GF(3191)/properties.json b/tests/fields/data/GF(3191)/properties.json
index d75e057ca..385c0c405 100644
--- a/tests/fields/data/GF(3191)/properties.json
+++ b/tests/fields/data/GF(3191)/properties.json
@@ -7,4 +7,4 @@
         1,
         3180
     ]
-}
\ No newline at end of file
+}
diff --git a/tests/fields/data/GF(36893488147419103183)/properties.json b/tests/fields/data/GF(36893488147419103183)/properties.json
index 131b417f1..f79abd0ee 100644
--- a/tests/fields/data/GF(36893488147419103183)/properties.json
+++ b/tests/fields/data/GF(36893488147419103183)/properties.json
@@ -7,4 +7,4 @@
         1,
         36893488147419103180
     ]
-}
\ No newline at end of file
+}
diff --git a/tests/fields/data/GF(5)/properties.json b/tests/fields/data/GF(5)/properties.json
index 2354ce0bf..cfe6e7c8f 100644
--- a/tests/fields/data/GF(5)/properties.json
+++ b/tests/fields/data/GF(5)/properties.json
@@ -7,4 +7,4 @@
         1,
         3
     ]
-}
\ No newline at end of file
+}
diff --git a/tests/fields/data/GF(7)/properties.json b/tests/fields/data/GF(7)/properties.json
index e45cef186..239be083b 100644
--- a/tests/fields/data/GF(7)/properties.json
+++ b/tests/fields/data/GF(7)/properties.json
@@ -7,4 +7,4 @@
         1,
         4
     ]
-}
\ No newline at end of file
+}
diff --git a/tests/fields/data/GF(7^3)/properties.json b/tests/fields/data/GF(7^3)/properties.json
index ab8231bca..7624ceae0 100644
--- a/tests/fields/data/GF(7^3)/properties.json
+++ b/tests/fields/data/GF(7^3)/properties.json
@@ -9,4 +9,4 @@
         0,
         4
     ]
-}
\ No newline at end of file
+}
diff --git a/tests/fields/data/GF(7^3, 643, 244)/properties.json b/tests/fields/data/GF(7^3, 643, 244)/properties.json
index c74521b7e..d0d7a5e13 100644
--- a/tests/fields/data/GF(7^3, 643, 244)/properties.json
+++ b/tests/fields/data/GF(7^3, 643, 244)/properties.json
@@ -9,4 +9,4 @@
         0,
         6
     ]
-}
\ No newline at end of file
+}