From bcbe191e9dd032f3995c80002b3a8b4345ed78d0 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Thu, 27 Jun 2024 18:06:12 +0100 Subject: [PATCH 01/33] chore: Add Ruff GitHub Actions workflow and update pre-commit configuration --- .github/workflows/rust.yml | 8 ++++++++ .pre-commit-config.yaml | 12 ++++++++---- ruff.toml | 12 ++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/rust.yml create mode 100644 ruff.toml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 000000000..ef06d34a9 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,8 @@ +name: Ruff +on: [ push, pull_request ] +jobs: + ruff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: chartboost/ruff-action@v1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a90d54b54..660a3ef75 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,11 @@ repos: hooks: - id: black language_version: python3.9 - - repo: https://github.com/pycqa/flake8 - rev: '6.1.0' - hooks: - - id: flake8 \ No newline at end of file + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.5.0 + hooks: + # Run the linter. + - id: ruff + # Run the formatter. + - id: ruff-format \ No newline at end of file diff --git a/ruff.toml b/ruff.toml new file mode 100644 index 000000000..50d109be0 --- /dev/null +++ b/ruff.toml @@ -0,0 +1,12 @@ +[lint] +# select = [] + +ignore = [ + "E501", # line-too-long +] + +exclude = ["test/**/*.py"] # ignore test files + +[lint.per-file-ignores] +"**/__init__.py" = ["F401", "E402"] # unused import, import not at top of file +# "./test/**/*.py" = ["E501", "F401", "E402"] # line-too-long, unused import, import not at top of file From b88c5b8fd8836a4827fcd13aba21e1d80d8cda4f Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Thu, 27 Jun 2024 18:11:32 +0100 Subject: [PATCH 02/33] trying to add ruff only on changed files --- .github/workflows/rust.yml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ef06d34a9..2258d433f 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,8 +1,25 @@ -name: Ruff +# name: Ruff +# on: [ push, pull_request ] +# jobs: +# ruff: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - uses: chartboost/ruff-action@v1 +name: Ruff on Changed Files + on: [ push, pull_request ] + jobs: ruff: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: chartboost/ruff-action@v1 + - uses: tj-actions/changed-files@v35 # Identify changed files + id: changed_files + - name: Run Ruff only on changes (optional) + run: | + if [[ $(echo ${{ steps.changed_files.outputs.all_changed_files }} | grep -q ".") ]]; then + # Use ruff-action with `--check` flag here + uses: chartboost/ruff-action@v1 with: args: --check + fi \ No newline at end of file From f53ff3da3ee3d86b97d554552d511011d45c3246 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Thu, 27 Jun 2024 18:14:11 +0100 Subject: [PATCH 03/33] bumping version --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2258d433f..2feb36b04 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: tj-actions/changed-files@v35 # Identify changed files + - uses: tj-actions/changed-files@v44 # Identify changed files id: changed_files - name: Run Ruff only on changes (optional) run: | From 88e79f0ae511971b937a61b14e90665b8fa2a8ce Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Thu, 27 Jun 2024 18:16:24 +0100 Subject: [PATCH 04/33] trying to trigger CI failure --- py4DSTEM/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/py4DSTEM/__init__.py b/py4DSTEM/__init__.py index d5df63f5e..0f2a568f0 100644 --- a/py4DSTEM/__init__.py +++ b/py4DSTEM/__init__.py @@ -91,3 +91,6 @@ from os.path import dirname, join _TESTPATH = join(dirname(__file__), "../test/unit_test_data") + +# adding a dumb error to test the CI +x = y + 10 \ No newline at end of file From 7191c4d94fa4568a4776c4e8e5b81a18af44d5c0 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Thu, 27 Jun 2024 18:25:11 +0100 Subject: [PATCH 05/33] updating action --- .github/workflows/rust.yml | 17 +++++------------ ruff.toml | 2 +- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2feb36b04..a0e83c5e3 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,14 +1,6 @@ -# name: Ruff -# on: [ push, pull_request ] -# jobs: -# ruff: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v4 -# - uses: chartboost/ruff-action@v1 name: Ruff on Changed Files -on: [ push, pull_request ] +on: [push, pull_request] jobs: ruff: @@ -19,7 +11,8 @@ jobs: id: changed_files - name: Run Ruff only on changes (optional) run: | - if [[ $(echo ${{ steps.changed_files.outputs.all_changed_files }} | grep -q ".") ]]; then + if [[ -n "${{ steps.changed_files.outputs.all_changed_files }}" ]]; then # Use ruff-action with `--check` flag here - uses: chartboost/ruff-action@v1 with: args: --check - fi \ No newline at end of file + uses: chartboost/ruff-action@v1 with: + args: --check + fi diff --git a/ruff.toml b/ruff.toml index 50d109be0..6ee2af5ca 100644 --- a/ruff.toml +++ b/ruff.toml @@ -8,5 +8,5 @@ ignore = [ exclude = ["test/**/*.py"] # ignore test files [lint.per-file-ignores] -"**/__init__.py" = ["F401", "E402"] # unused import, import not at top of file +"**/__init__.py" = ["F401", "F403", "E402"] # "./test/**/*.py" = ["E501", "F401", "E402"] # line-too-long, unused import, import not at top of file From 7fc8f76c74583ed4a0f4aa79ae804ec4845be853 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Thu, 27 Jun 2024 18:27:51 +0100 Subject: [PATCH 06/33] another attempt --- .github/workflows/rust.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a0e83c5e3..7a9f96beb 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -7,12 +7,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: tj-actions/changed-files@v44 # Identify changed files - id: changed_files - - name: Run Ruff only on changes (optional) - run: | - if [[ -n "${{ steps.changed_files.outputs.all_changed_files }}" ]]; then - # Use ruff-action with `--check` flag here - uses: chartboost/ruff-action@v1 with: - args: --check - fi + - uses: chartboost/ruff-action@v1 + with: + changed-files: 'true' From 2105dec3e2ded9c3ee1ea8bf87f34fe8fb740b08 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Thu, 27 Jun 2024 18:28:20 +0100 Subject: [PATCH 07/33] another another test --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7a9f96beb..558d8fcd5 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -9,4 +9,4 @@ jobs: - uses: actions/checkout@v4 - uses: chartboost/ruff-action@v1 with: - changed-files: 'true' + changed-files: 'true' From 909ddfa0111d090a165c7818857bef20cb64cfe3 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Thu, 27 Jun 2024 18:50:37 +0100 Subject: [PATCH 08/33] reverting the change --- py4DSTEM/__init__.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/py4DSTEM/__init__.py b/py4DSTEM/__init__.py index 0f2a568f0..d5df63f5e 100644 --- a/py4DSTEM/__init__.py +++ b/py4DSTEM/__init__.py @@ -91,6 +91,3 @@ from os.path import dirname, join _TESTPATH = join(dirname(__file__), "../test/unit_test_data") - -# adding a dumb error to test the CI -x = y + 10 \ No newline at end of file From 3338ab439d87f3f898a97e735c457d2e47bbd537 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Thu, 27 Jun 2024 18:51:14 +0100 Subject: [PATCH 09/33] updating to ignore to see if it passes CI --- .github/workflows/rust.yml | 4 +--- ruff.toml | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 558d8fcd5..3f8506550 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -7,6 +7,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: chartboost/ruff-action@v1 - with: - changed-files: 'true' + - uses: chartboost/ruff-action@v1 \ No newline at end of file diff --git a/ruff.toml b/ruff.toml index 6ee2af5ca..205c1b5a7 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,8 +1,36 @@ [lint] -# select = [] +# 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", # unspecified import + "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 + ] exclude = ["test/**/*.py"] # ignore test files From 4ec5a926f712bf4b2e5f35efd5321833e024c17e Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Thu, 27 Jun 2024 18:58:00 +0100 Subject: [PATCH 10/33] adding rule update --- .github/workflows/rust.yml | 3 ++- ruff.toml | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3f8506550..5edc1004a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -7,4 +7,5 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: chartboost/ruff-action@v1 \ No newline at end of file + - uses: chartboost/ruff-action@v1 + \ No newline at end of file diff --git a/ruff.toml b/ruff.toml index 205c1b5a7..f073366da 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,3 +1,5 @@ +required-version = ">=0.5.0" +target-version = "py39" [lint] # select = [ # # "F402", # module level import not at top of file @@ -30,6 +32,7 @@ ignore = [ "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 ] From 90d77a20fe52f3f3eab697b08de097996da1ecc7 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Thu, 27 Jun 2024 18:58:56 +0100 Subject: [PATCH 11/33] change name --- .github/workflows/rust.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 5edc1004a..f8e4f11ff 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,4 +1,4 @@ -name: Ruff on Changed Files +name: Ruff on: [push, pull_request] @@ -8,4 +8,3 @@ jobs: steps: - uses: actions/checkout@v4 - uses: chartboost/ruff-action@v1 - \ No newline at end of file From 290637653d9f1f4c995ec318ccb7e6dba3da7c45 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 21:25:18 +0100 Subject: [PATCH 12/33] Add GitHub Actions workflow for running Ruff on changed files --- .github/workflows/changed_rust.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/changed_rust.yml diff --git a/.github/workflows/changed_rust.yml b/.github/workflows/changed_rust.yml new file mode 100644 index 000000000..10c83c924 --- /dev/null +++ b/.github/workflows/changed_rust.yml @@ -0,0 +1,30 @@ +name: Run Ruff on Changed Files + +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 + run: | + ruff check ${{ steps.changed-files.outputs.all_changed_files }} + From 328903ef5bc35c2a720870f72f301bf2720927cb Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 21:25:30 +0100 Subject: [PATCH 13/33] adding error to trigger CI --- py4DSTEM/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py4DSTEM/__init__.py b/py4DSTEM/__init__.py index d5df63f5e..ef94eef14 100644 --- a/py4DSTEM/__init__.py +++ b/py4DSTEM/__init__.py @@ -1,7 +1,7 @@ from py4DSTEM.version import __version__ from emdfile import tqdmnd - +y = 6 + x ### io # substructure From 8b6ebfa0a4bc82e18a51768fb2b04cc47308b5f7 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 21:28:44 +0100 Subject: [PATCH 14/33] reducing ignored ruff rules --- ruff.toml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ruff.toml b/ruff.toml index f073366da..a776f712d 100644 --- a/ruff.toml +++ b/ruff.toml @@ -17,22 +17,22 @@ target-version = "py39" ignore = [ "E501", # line-too-long "F401", # unspecified import - "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 + # "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 ] From 90772642f99d64e73b4f4bdbb4f23e1049b11dc7 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 21:45:52 +0100 Subject: [PATCH 15/33] trying again --- .github/workflows/changed_rust.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/changed_rust.yml b/.github/workflows/changed_rust.yml index 10c83c924..ca3fc5a00 100644 --- a/.github/workflows/changed_rust.yml +++ b/.github/workflows/changed_rust.yml @@ -25,6 +25,11 @@ jobs: run: pip install ruff - name: Run Ruff on changed files + env: + ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} run: | - ruff check ${{ steps.changed-files.outputs.all_changed_files }} + for file in ${ALL_CHANGED_FILES}; do + echo "$file was changed" + done + ruff check ${ALL_CHANGED_FILES} From ecef76ea170049808690781d8629e3d37c2c2c6c Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 21:46:07 +0100 Subject: [PATCH 16/33] trying again --- .github/workflows/changed_rust.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/changed_rust.yml b/.github/workflows/changed_rust.yml index ca3fc5a00..298088910 100644 --- a/.github/workflows/changed_rust.yml +++ b/.github/workflows/changed_rust.yml @@ -30,6 +30,6 @@ jobs: run: | for file in ${ALL_CHANGED_FILES}; do echo "$file was changed" - done - ruff check ${ALL_CHANGED_FILES} + done + # ruff check ${ALL_CHANGED_FILES} From 4b6caf6cf8119692a646093daaf0bf99d7317549 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 21:47:14 +0100 Subject: [PATCH 17/33] adding another erroed file --- py4DSTEM/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py4DSTEM/__init__.py b/py4DSTEM/__init__.py index ef94eef14..ee53cd276 100644 --- a/py4DSTEM/__init__.py +++ b/py4DSTEM/__init__.py @@ -1,7 +1,7 @@ from py4DSTEM.version import __version__ from emdfile import tqdmnd -y = 6 + x +y = 20 + x ### io # substructure From b46ac140be9f93adcbf69674031747bdcc9ea1d5 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 21:48:06 +0100 Subject: [PATCH 18/33] adding new yml --- .github/workflows/changed_rust.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/changed_rust.yml b/.github/workflows/changed_rust.yml index 298088910..2d6e32622 100644 --- a/.github/workflows/changed_rust.yml +++ b/.github/workflows/changed_rust.yml @@ -28,8 +28,8 @@ jobs: env: ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} run: | - for file in ${ALL_CHANGED_FILES}; do - echo "$file was changed" - done - # ruff check ${ALL_CHANGED_FILES} + # for file in ${ALL_CHANGED_FILES}; do + # echo "$file was changed" + # done + ruff check ${ALL_CHANGED_FILES} From 79d8e6fd0d7320737e4a14234d7a417142dcc024 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 21:48:21 +0100 Subject: [PATCH 19/33] adding errored file --- py4DSTEM/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py4DSTEM/__init__.py b/py4DSTEM/__init__.py index ee53cd276..79502f585 100644 --- a/py4DSTEM/__init__.py +++ b/py4DSTEM/__init__.py @@ -1,7 +1,7 @@ from py4DSTEM.version import __version__ from emdfile import tqdmnd -y = 20 + x +y = 250 + x ### io # substructure From ae64d83991cf290990a1df292422caa249692833 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 21:49:30 +0100 Subject: [PATCH 20/33] adding multiple errored files --- py4DSTEM/__init__.py | 2 +- py4DSTEM/utils/__init__.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/py4DSTEM/__init__.py b/py4DSTEM/__init__.py index 79502f585..39efdad66 100644 --- a/py4DSTEM/__init__.py +++ b/py4DSTEM/__init__.py @@ -1,7 +1,7 @@ from py4DSTEM.version import __version__ from emdfile import tqdmnd -y = 250 + x +y = 2500 + x ### io # substructure diff --git a/py4DSTEM/utils/__init__.py b/py4DSTEM/utils/__init__.py index b0c484e80..5350e29bf 100644 --- a/py4DSTEM/utils/__init__.py +++ b/py4DSTEM/utils/__init__.py @@ -1 +1,2 @@ from py4DSTEM.utils.configuration_checker import check_config +y = 23 * z \ No newline at end of file From 08dfc4ebbcc755be9bbc7ad02574f2d89700024b Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 21:54:50 +0100 Subject: [PATCH 21/33] removing errored files --- py4DSTEM/__init__.py | 1 - py4DSTEM/utils/__init__.py | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/py4DSTEM/__init__.py b/py4DSTEM/__init__.py index 39efdad66..429ef8d84 100644 --- a/py4DSTEM/__init__.py +++ b/py4DSTEM/__init__.py @@ -1,7 +1,6 @@ from py4DSTEM.version import __version__ from emdfile import tqdmnd -y = 2500 + x ### io # substructure diff --git a/py4DSTEM/utils/__init__.py b/py4DSTEM/utils/__init__.py index 5350e29bf..fd2b917ac 100644 --- a/py4DSTEM/utils/__init__.py +++ b/py4DSTEM/utils/__init__.py @@ -1,2 +1 @@ -from py4DSTEM.utils.configuration_checker import check_config -y = 23 * z \ No newline at end of file +from py4DSTEM.utils.configuration_checker import check_config \ No newline at end of file From 32d9fd3d17d198f59623dde191521e955f70ccd7 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 22:06:38 +0100 Subject: [PATCH 22/33] removing ruff formatter from pre commit --- .pre-commit-config.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 660a3ef75..d92847e48 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,6 +10,4 @@ repos: rev: v0.5.0 hooks: # Run the linter. - - id: ruff - # Run the formatter. - - id: ruff-format \ No newline at end of file + - id: ruff \ No newline at end of file From d5de04f958efce5589d6bb9e264f707d36f5b12f Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 22:20:07 +0100 Subject: [PATCH 23/33] updating pre-commit --- .pre-commit-config.yaml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d92847e48..bedc2082e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,8 +6,6 @@ repos: - id: black language_version: python3.9 - repo: https://github.com/astral-sh/ruff-pre-commit - # Ruff version. - rev: v0.5.0 - hooks: - # Run the linter. - - id: ruff \ No newline at end of file + rev: v0.5.0 + hooks: + - id: ruff \ No newline at end of file From 150422e84c2e1bc54101ba1c896154b415d4e444 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 22:20:19 +0100 Subject: [PATCH 24/33] updating ruff.toml --- ruff.toml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ruff.toml b/ruff.toml index a776f712d..f69c58005 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,6 +1,7 @@ required-version = ">=0.5.0" target-version = "py39" [lint] +# From Flake8 config # select = [ # # "F402", # module level import not at top of file # # "F404", # future import not at top of file @@ -16,7 +17,9 @@ target-version = "py39" ignore = [ "E501", # line-too-long - "F401", # unspecified import + "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 @@ -39,5 +42,10 @@ ignore = [ exclude = ["test/**/*.py"] # ignore test files [lint.per-file-ignores] -"**/__init__.py" = ["F401", "F403", "E402"] +# 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 From 22386a072e0707af9cb2e8709ca2ef306bfb9500 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 22:24:07 +0100 Subject: [PATCH 25/33] changing name of rust GHA --- .github/workflows/changed_rust.yml | 35 ------------------------------ .github/workflows/rust.yml | 35 +++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 40 deletions(-) delete mode 100644 .github/workflows/changed_rust.yml diff --git a/.github/workflows/changed_rust.yml b/.github/workflows/changed_rust.yml deleted file mode 100644 index 2d6e32622..000000000 --- a/.github/workflows/changed_rust.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Run Ruff on Changed Files - -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: | - # for file in ${ALL_CHANGED_FILES}; do - # echo "$file was changed" - # done - ruff check ${ALL_CHANGED_FILES} - diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f8e4f11ff..2d6e32622 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,10 +1,35 @@ -name: Ruff +name: Run Ruff on Changed Files -on: [push, pull_request] +on: + push: + pull_request: jobs: - ruff: + lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: chartboost/ruff-action@v1 + - 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: | + # for file in ${ALL_CHANGED_FILES}; do + # echo "$file was changed" + # done + ruff check ${ALL_CHANGED_FILES} + From 13c1be8a4f0939a311830f4b573b6b308f6f723c Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 22:24:21 +0100 Subject: [PATCH 26/33] removing flake8 runs --- .github/linters/.flake8 | 2 -- .github/workflows/build-flake.yml | 40 ------------------------------- .github/workflows/linter.yml | 25 ------------------- 3 files changed, 67 deletions(-) delete mode 100644 .github/linters/.flake8 delete mode 100644 .github/workflows/build-flake.yml delete mode 100644 .github/workflows/linter.yml diff --git a/.github/linters/.flake8 b/.github/linters/.flake8 deleted file mode 100644 index e30e76b99..000000000 --- a/.github/linters/.flake8 +++ /dev/null @@ -1,2 +0,0 @@ -[flake8] -select: "F402,F404,F812,F823,F831,F821,F822,E112,E113,E901,E902,E999" diff --git a/.github/workflows/build-flake.yml b/.github/workflows/build-flake.yml deleted file mode 100644 index 3bf56d698..000000000 --- a/.github/workflows/build-flake.yml +++ /dev/null @@ -1,40 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a single version of Python -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Check module can be imported - -on: - push: - branches: [ "dev" ] - pull_request: - branches: [ "dev" ] - -permissions: - contents: read - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - name: Set up Python 3.10 - uses: actions/setup-python@v5 - with: - python-version: "3.10" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - - name: Lint with flake8 - run: | - # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - - name: Test that the module imports - run: | - pip install . - python -c "import py4DSTEM; print(py4DSTEM.__version__)" diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml deleted file mode 100644 index 550998606..000000000 --- a/.github/workflows/linter.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Check for errors with flake8 - -on: - push: - branches: [ "dev" ] - pull_request: - branches: [ "dev" ] - -jobs: - run-lint: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - # Full git history is needed to get a proper list of changed files within `super-linter` - fetch-depth: 0 - - - name: Lint Code Base - uses: github/super-linter@v6 - env: - VALIDATE_ALL_CODEBASE: false - VALIDATE_PYTHON_FLAKE8: true - DEFAULT_BRANCH: "dev" - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 73a157e83416d5c018cc061990806daf4d05e316 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 22:26:12 +0100 Subject: [PATCH 27/33] typo name --- .github/workflows/{rust.yml => ruff.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{rust.yml => ruff.yml} (100%) diff --git a/.github/workflows/rust.yml b/.github/workflows/ruff.yml similarity index 100% rename from .github/workflows/rust.yml rename to .github/workflows/ruff.yml From b30f023d7e5d3b76e9b13526090cb6ab0fe5fafb Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 22:28:17 +0100 Subject: [PATCH 28/33] Rename GitHub Actions workflow to "Ruff Check" --- .github/workflows/ruff.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 2d6e32622..2dcf82940 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -1,4 +1,4 @@ -name: Run Ruff on Changed Files +name: Ruff Check on: push: From 1442fd92d9ad20e84e9f3b6441960355145098ce Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 22:33:35 +0100 Subject: [PATCH 29/33] Add conditional check for changed files in GitHub Actions workflow --- .github/workflows/ruff.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index 2dcf82940..fb71c3bae 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -28,8 +28,13 @@ jobs: env: ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} run: | - # for file in ${ALL_CHANGED_FILES}; do - # echo "$file was changed" - # done - ruff check ${ALL_CHANGED_FILES} + - 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 From 3e87930e667219af34ee668f0ff6fc4c06a0d50d Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 22:35:54 +0100 Subject: [PATCH 30/33] adding errored file --- py4DSTEM/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/py4DSTEM/__init__.py b/py4DSTEM/__init__.py index 429ef8d84..d680efdde 100644 --- a/py4DSTEM/__init__.py +++ b/py4DSTEM/__init__.py @@ -1,6 +1,7 @@ from py4DSTEM.version import __version__ from emdfile import tqdmnd +z = 28 * y ### io # substructure From b23f28e2d5c11ff9954ddc7a3401a9270c54f015 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 22:36:44 +0100 Subject: [PATCH 31/33] removing errored file --- py4DSTEM/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/py4DSTEM/__init__.py b/py4DSTEM/__init__.py index d680efdde..429ef8d84 100644 --- a/py4DSTEM/__init__.py +++ b/py4DSTEM/__init__.py @@ -1,7 +1,6 @@ from py4DSTEM.version import __version__ from emdfile import tqdmnd -z = 28 * y ### io # substructure From c2ce307f6153b1df994f34985757fd6e4cf1f4a4 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Sat, 29 Jun 2024 22:38:11 +0100 Subject: [PATCH 32/33] non .py file change to trigger CI --- ruff.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruff.toml b/ruff.toml index f69c58005..237ab5039 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,5 +1,5 @@ required-version = ">=0.5.0" -target-version = "py39" +target-version = "py311" [lint] # From Flake8 config # select = [ From d61bfb6251cdcec66087281b148b7d016e1cbb15 Mon Sep 17 00:00:00 2001 From: alex-rakowski Date: Fri, 12 Jul 2024 01:07:51 +0100 Subject: [PATCH 33/33] formatting --- py4DSTEM/utils/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py4DSTEM/utils/__init__.py b/py4DSTEM/utils/__init__.py index fd2b917ac..b0c484e80 100644 --- a/py4DSTEM/utils/__init__.py +++ b/py4DSTEM/utils/__init__.py @@ -1 +1 @@ -from py4DSTEM.utils.configuration_checker import check_config \ No newline at end of file +from py4DSTEM.utils.configuration_checker import check_config