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

A little Ruff around the edges #667

Open
wants to merge 33 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bcbe191
chore: Add Ruff GitHub Actions workflow and update pre-commit configu…
alex-rakowski Jun 27, 2024
b88c5b8
trying to add ruff only on changed files
alex-rakowski Jun 27, 2024
f53ff3d
bumping version
alex-rakowski Jun 27, 2024
88e79f0
trying to trigger CI failure
alex-rakowski Jun 27, 2024
7191c4d
updating action
alex-rakowski Jun 27, 2024
7fc8f76
another attempt
alex-rakowski Jun 27, 2024
2105dec
another another test
alex-rakowski Jun 27, 2024
909ddfa
reverting the change
alex-rakowski Jun 27, 2024
3338ab4
updating to ignore to see if it passes CI
alex-rakowski Jun 27, 2024
4ec5a92
adding rule update
alex-rakowski Jun 27, 2024
90d77a2
change name
alex-rakowski Jun 27, 2024
2906376
Add GitHub Actions workflow for running Ruff on changed files
alex-rakowski Jun 29, 2024
328903e
adding error to trigger CI
alex-rakowski Jun 29, 2024
8b6ebfa
reducing ignored ruff rules
alex-rakowski Jun 29, 2024
9077264
trying again
alex-rakowski Jun 29, 2024
ecef76e
trying again
alex-rakowski Jun 29, 2024
4b6caf6
adding another erroed file
alex-rakowski Jun 29, 2024
b46ac14
adding new yml
alex-rakowski Jun 29, 2024
79d8e6f
adding errored file
alex-rakowski Jun 29, 2024
ae64d83
adding multiple errored files
alex-rakowski Jun 29, 2024
08dfc4e
removing errored files
alex-rakowski Jun 29, 2024
32d9fd3
removing ruff formatter from pre commit
alex-rakowski Jun 29, 2024
d5de04f
updating pre-commit
alex-rakowski Jun 29, 2024
150422e
updating ruff.toml
alex-rakowski Jun 29, 2024
22386a0
changing name of rust GHA
alex-rakowski Jun 29, 2024
13c1be8
removing flake8 runs
alex-rakowski Jun 29, 2024
73a157e
typo name
alex-rakowski Jun 29, 2024
b30f023
Rename GitHub Actions workflow to "Ruff Check"
alex-rakowski Jun 29, 2024
1442fd9
Add conditional check for changed files in GitHub Actions workflow
alex-rakowski Jun 29, 2024
3e87930
adding errored file
alex-rakowski Jun 29, 2024
b23f28e
removing errored file
alex-rakowski Jun 29, 2024
c2ce307
non .py file change to trigger CI
alex-rakowski Jun 29, 2024
d61bfb6
formatting
alex-rakowski Jul 12, 2024
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
2 changes: 0 additions & 2 deletions .github/linters/.flake8

This file was deleted.

40 changes: 0 additions & 40 deletions .github/workflows/build-flake.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/linter.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Ruff Check

on:
push:
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Get all commits

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: '**/*.py' # Adjust pattern for your file types

- name: Setup Python environment
uses: actions/setup-python@v3

- name: Install Ruff
run: pip install ruff

- name: Run Ruff on changed files
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
- run: |
if [ -n "${ALL_CHANGED_FILES}" ]; then
# for file in ${ALL_CHANGED_FILES}; do
# echo "$file was changed"
# done
ruff check ${ALL_CHANGED_FILES}
else
echo "No files changed"
fi

6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
hooks:
- id: black
language_version: python3.9
- repo: https://github.com/pycqa/flake8
rev: '6.1.0'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.0
hooks:
- id: flake8
- id: ruff
1 change: 0 additions & 1 deletion py4DSTEM/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from py4DSTEM.version import __version__
from emdfile import tqdmnd


### io

# substructure
Expand Down
51 changes: 51 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
required-version = ">=0.5.0"
target-version = "py311"
[lint]
# From Flake8 config
# select = [
# # "F402", # module level import not at top of file
# # "F404", # future import not at top of file
# # # "F812", # list comprehension redefines name from outer scope
# # "F823", # local variable name referenced before assignment
# # # "F831", # duplicate argument name in function definition
# # "F821", # undefined name
# # "F822", # undefined name in __all__
# # "E112", # expected an indented block
# # "E902", # IOError
# # # "E999", # SyntaxError deprecated since
# ]

ignore = [
"E501", # line-too-long
"F401", # unused import

# exisiting errors in code base
# "E721", # do not compare types, use 'isinstance()'
# "F841", # local variable is assigned to but never used
# "E741", # ambiguous variable name
# "F541", # f-string is missing placeholders
# "E731", # do not assign a lambda expression, use a def
# "E714", # test for object identity should be 'is not'
# "F811", # redefinition of unused name
# "E722", # do not use bare except
# "F405", # name may be undefined, or defined from star imports
# "F523", # string-dot-format-extra-positional-argument
# "F403", # unable to detect undefined names
# "F524", # string-dot-format-missing-arguments
# "E402", # module level import not at top of file
# "E713", # test for membership should be 'not in'
# "E743", # ambiguous function name
# "E712", # true-false-comparison

]

exclude = ["test/**/*.py"] # ignore test files

[lint.per-file-ignores]
# Ignore specific lint errors for __init__.py files
"**/__init__.py" = [
"F401", # Unspecified import
"F403", # Unable to detect undefined names
"E402" # Module level import not at top of file
]
# "./test/**/*.py" = ["E501", "F401", "E402"] # line-too-long, unused import, import not at top of file
Loading