Skip to content

Commit 5c0794c

Browse files
authored
Merge pull request #683 from Mathics3/add-isort-reformatting
Add isort as a pre-commit hook and as a CI check
2 parents 42f085e + 60a6cde commit 5c0794c

File tree

182 files changed

+523
-1021
lines changed

Some content is hidden

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

182 files changed

+523
-1021
lines changed

.github/workflows/autoblack.yml renamed to .github/workflows/isort-and-black-checks.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Othewrwise, Black is run and its changes are committed back to the incoming pull request.
44
# https://github.com/cclauss/autoblack
55

6-
name: autoblack
6+
name: isort and black check
77
on: [pull_request]
88
jobs:
99
build:
@@ -14,11 +14,11 @@ jobs:
1414
uses: actions/setup-python@v2
1515
with:
1616
python-version: 3.9
17-
- name: Install click
18-
run: pip install 'click==8.0.4'
19-
- name: Install Black
20-
run: pip install 'black==22.3.0'
21-
- name: Run black --check .
17+
- name: Install click, black and isort
18+
run: pip install 'click==8.0.4' 'black==22.3.0' 'isort==5.10.1'
19+
- name: Run isort --check .
20+
run: isort --check .
21+
- name: Run isort --check .
2222
run: black --check .
2323
- name: If needed, commit black changes to the pull request
2424
if: failure()

.isort.cfg

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[settings]
2+
multi_line_output = 3
3+
include_trailing_comma = True
4+
force_grid_wrap = 0
5+
use_parentheses = True
6+
line_length = 88
7+
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,CRUNCH,LOCALFOLDER
8+
default_section = THIRDPARTY
9+
combine_as_imports = 1
10+
profile = black

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ repos:
99
stages: [commit]
1010
- id: end-of-file-fixer
1111
stages: [commit]
12+
- repo: https://github.com/pycqa/isort
13+
rev: 5.10.1
14+
hooks:
15+
- id: isort
16+
stages: [commit]
1217
- repo: https://github.com/psf/black
1318
rev: 22.3.0
1419
hooks:

admin-tools/build_and_check_manifest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/env python
22

3-
from mathics.builtin import name_is_builtin_symbol, modules, Builtin
43
import sys
54

5+
from mathics.builtin import Builtin, modules, name_is_builtin_symbol
6+
67

78
def generate_available_builtins_names():
89
msg = ""

admin-tools/time-mathmp-sympy-fns.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
Program to time mpmath pi vs sympy pi
44
"""
55

6+
import math
67
from timeit import timeit
8+
79
import mpmath
8-
import math
910
import sympy
1011

1112
PRECISION = 100

mathics/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# -*- coding: utf-8 -*-
22

3-
import sys
43
import platform
5-
import sympy
4+
import sys
5+
66
import mpmath
77
import numpy
8+
import sympy
89

910
from mathics.version import __version__
1011

mathics/algorithm/clusters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# -*- coding: utf-8 -*-
22

33

4-
import random
5-
from itertools import chain, islice
64
import bisect
75
import math
6+
import random
7+
from itertools import chain, islice
88

99
from mpmath import fsum
1010

mathics/algorithm/integrators.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,11 @@
22

33
import numpy as np
44

5-
from mathics.core.number import machine_epsilon
5+
from mathics.core.atoms import Integer, Integer0, Number
66
from mathics.core.expression import Expression
7-
from mathics.core.atoms import (
8-
Integer,
9-
Integer0,
10-
Number,
11-
)
12-
137
from mathics.core.list import ListExpression
8+
from mathics.core.number import machine_epsilon
149
from mathics.core.symbols import Symbol, SymbolPlus, SymbolSequence, SymbolTimes
15-
16-
1710
from mathics.core.systemsymbols import (
1811
SymbolBlank,
1912
SymbolComplex,

mathics/algorithm/introselect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ def introselect(a, k): # changes a
164164

165165

166166
if __name__ == "__main__":
167-
import random
168167
import itertools
168+
import random
169169

170170
def test_algorithm(l, r_max, name, f):
171171
a = [random.randint(-r_max, r_max) for _ in range(l)]

mathics/algorithm/optimizers.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,22 @@
33
from typing import Optional
44

55
from mathics.builtin.scoping import dynamic_scoping
6-
7-
86
from mathics.core.atoms import (
9-
String,
107
Integer,
118
Integer0,
12-
IntegerM1,
139
Integer1,
1410
Integer2,
1511
Integer3,
1612
Integer10,
13+
IntegerM1,
1714
Number,
1815
Real,
16+
String,
1917
)
2018
from mathics.core.convert.python import from_python
2119
from mathics.core.evaluation import Evaluation
22-
from mathics.eval.nevaluator import eval_N
2320
from mathics.core.expression import Expression
24-
from mathics.core.symbols import (
25-
BaseElement,
26-
SymbolPlus,
27-
SymbolTimes,
28-
SymbolTrue,
29-
)
30-
21+
from mathics.core.symbols import BaseElement, SymbolPlus, SymbolTimes, SymbolTrue
3122
from mathics.core.systemsymbols import (
3223
SymbolAutomatic,
3324
SymbolD,
@@ -37,6 +28,7 @@
3728
SymbolLog,
3829
SymbolNone,
3930
)
31+
from mathics.eval.nevaluator import eval_N
4032

4133

4234
def find_minimum_newton1d(f, x0, x, opts, evaluation) -> (Number, bool):

0 commit comments

Comments
 (0)