Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github Actions: autoformat with black #307

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0d3c15b
Update build.yml for flake8 and black
annabel48lin Apr 17, 2021
44ba95d
added to pipfile, edited args
annabel48lin Apr 18, 2021
eb222ed
Update build.yml
annabel48lin Apr 18, 2021
47fb3e5
Update build.yml
annabel48lin Apr 18, 2021
a768d6c
Update build.yml
annabel48lin Apr 18, 2021
97e9928
Update Pipfile.lock
annabel48lin Apr 18, 2021
f64c3b0
Update build.yml
annabel48lin Apr 18, 2021
94725b4
Update build.yml
annabel48lin Apr 18, 2021
f949722
Revert "Update build.yml"
annabel48lin Apr 20, 2021
5adc9ec
Update build.yml
annabel48lin Apr 20, 2021
e936687
try to see where flake8 is
annabel48lin Apr 20, 2021
f8d4f09
hoping that this will work. Moved flake8 to packages
annabel48lin Apr 20, 2021
d2b8d1b
Update Pipfile
annabel48lin May 1, 2021
f8fde07
pipenv install black --pre
annabel48lin May 1, 2021
bd9429b
python -m flake8
annabel48lin May 1, 2021
a66dcb3
added lint section
annabel48lin May 1, 2021
596951a
python -m flake8
annabel48lin May 1, 2021
7352bfb
python -m pip install flake8
annabel48lin May 1, 2021
f8d9c26
move black first
annabel48lin May 1, 2021
d25c06e
moved packages to dev
annabel48lin May 1, 2021
822e402
pipenv run
annabel48lin May 1, 2021
91ac77c
remove --check
annabel48lin May 1, 2021
83dd5a0
add check back to black, comment out flake8
annabel48lin May 1, 2021
b7347ea
remove other black options
annabel48lin May 1, 2021
3f21173
used black to format code
annabel48lin May 1, 2021
71c72da
Revert "used black to format code"
annabel48lin May 1, 2021
c01952c
trying to get it to push black changes
annabel48lin May 1, 2021
169ce2d
forgot if: failure()
annabel48lin May 1, 2021
3856589
fixup: Format Python code with Black
annabel48lin May 1, 2021
fb97f92
update to use psf's third party action
annabel48lin May 8, 2021
53f4da1
format instead of check
annabel48lin May 8, 2021
bacaad8
Update build.yml
annabel48lin May 8, 2021
78e8ef3
Update build.yml
annabel48lin May 8, 2021
80c4154
Update build.yml
annabel48lin May 8, 2021
c1d92b8
trying a different action to actually write files
annabel48lin May 8, 2021
a1a5e25
commit changes
annabel48lin May 8, 2021
5822067
Apply black formatting
annabel48lin May 8, 2021
9c0dbdc
update dev guide and comment
annabel48lin May 9, 2021
6cccdbd
Merge branch 'master' into all273/github-actions
annabel48lin May 9, 2021
219fd1e
Revert "Merge branch 'master' into all273/github-actions"
annabel48lin May 9, 2021
bffe1c5
merged Vaishnavi's cdc changes (it was glitchy earlier)
annabel48lin May 9, 2021
b2ce8e5
Apply black formatting
annabel48lin May 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@ jobs:
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: true


autoformat:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
# format code
- uses: piotrpawlaczek/python-blacken@release/stable
with:
only-check: 'no'
# push formatted code
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply black formatting

# - name: Lint with flake8
# run: |
# pipenv run flake8 aguaclara --count --verbose --show-source --statistics


test-docs:
runs-on: ubuntu-latest
Expand Down
10 changes: 8 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

# Ensure that this matches setup.py > setup() > install_requires

[packages]
matplotlib = "*"
urllib3 = "*"
Expand All @@ -12,6 +12,7 @@ pandas = "*"
scipy = "*"
onshape_client = "*"


[dev-packages]
aguaclara = {editable = true, path = "."}
autopep8 = "*"
Expand All @@ -26,4 +27,9 @@ colorama = {version = "*", sys.platform = "win32"} # pytest dependency
requests = ">=2.20.0" # Resolves security vulnerability
rope = "*"
Sphinx = "*"
sphinx_rtd_theme = "*"
sphinx_rtd_theme = "*"
flake8 = "*"
black = "*"

[pipenv]
allow_prereleases = true
705 changes: 396 additions & 309 deletions Pipfile.lock

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions aguaclara/core/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ def ac_hash(hashable_object):
a_hash = ac_hash_iterable_into_tuple(hashable_object)
else:
a_hash = repr(hashable_object)
warnings.warn("Using repr() to make a hash of {}. Please consider inheriting HashableObject class as repr "
"will not guarantee replicable hashing and can result in bad cache returns.".format(
repr(hashable_object)), Warning, stacklevel=2)
warnings.warn(
"Using repr() to make a hash of {}. Please consider inheriting HashableObject class as repr "
"will not guarantee replicable hashing and can result in bad cache returns.".format(
repr(hashable_object)
),
Warning,
stacklevel=2,
)
return a_hash

def ac_hash_iterable_into_tuple(hashable_object_list):
Expand All @@ -44,11 +49,13 @@ def ac_hash_iterable_into_tuple(hashable_object_list):
return hash_tuple

primitive = (int, str, bool, ...)

def is_simple_hashable(thing):
return type(thing) in primitive

return _cache


class HashableObject:
def ac_hash(self):
return tuple(sorted(self.__dict__.items()))
return tuple(sorted(self.__dict__.items()))
20 changes: 12 additions & 8 deletions aguaclara/core/drills.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@ def get_drill_bits_d_imperial():
step_4th = np.arange(1.0, 2.0, 0.25)
maximum = [2.0]

return np.concatenate((step_32nd,
step_8th,
step_4th,
maximum)) * u.inch
return np.concatenate((step_32nd, step_8th, step_4th, maximum)) * u.inch


def get_drill_bits_d_metric():
"""Return array of possible drill diameters in metric."""
return np.concatenate((np.arange(1.0, 10.0, 0.1),
np.arange(10.0, 18.0, 0.5),
np.arange(18.0, 36.0, 1.0),
np.arange(40.0, 55.0, 5.0))) * u.mm
return (
np.concatenate(
(
np.arange(1.0, 10.0, 0.1),
np.arange(10.0, 18.0, 0.5),
np.arange(18.0, 36.0, 1.0),
np.arange(40.0, 55.0, 5.0),
)
)
* u.mm
)


DRILL_BITS_D_IMPERIAL = get_drill_bits_d_imperial()
Expand Down
Loading