From 0bc5489fbe7275040ee39f249c1c9a5b57cb6e8e Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Tue, 29 Oct 2024 08:17:40 -0400 Subject: [PATCH 1/6] Include codespell and improved instructions for flake8 error --- README.md | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 3eda25d..7e5233f 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Create a new conda environment that includes the cookiecutter package by running ```bash # Download from PyPI pip install cookiecutter +pip install black pre-commit ``` and follow the instructions provided below. @@ -32,22 +33,26 @@ For instance, there may be a more verbose description of what the package does, ### 1. Pre-commit workflow -1. In your `dev` folder, fork and clone the package that you are preparing for release. +1. In your `dev` folder, fork and clone the package 2. `cd` into the top level directory of that project. -3. `git pull upstream main` (make sure you are synchronized). -4. Double check that no bug-fix etc. pull-requests are waiting to be merged. May as well get them merged before doing this. Check with Simon if not sure.. +3. Type `git pull upstream main` to sync with the main brannch. +4. Double check that no bug-fix etc. pull-requests are waiting to be merged. Check with Simon if not sure. 5. Create a new branch called `black`. -6. Edit the `pyproject.toml` so the section `[tools.black]` is consistent with `pyproject.toml` in `{{ cookiecutter.repo_name }}`. -7. Activate a Conda env that contains black and run `black src` (note: some of the older packages do not have an `src` directory, so you may have to run black on a different directory). -8. If it runs successfully and makes changes, commit the changes. -9. Let's run black on everything else. Run `black .` and make a PR. -11. When the PR is merged, `git checkout main && git pull upstream main` and create a new branch called `precommit`. +6. Create `pyproject.toml`. Copy and paste the `[tools.black]` and `[tool.codespell]` sections from `pyproject.toml` in the `{{ cookiecutter.repo_name }}` folder path. +7. Run `black src` (note: some of the older packages do not have an `src` directory, so you may have to run black on a different directory). +8. Commit the automatic changes by `black`. +9. Run `black .` and create a PR into `main`. Follow the group's GitHub worfklow tutorial on GitLab. +10. After the `black` branch has been merged, run pytest or unit tests to ensure all tests pass locally. If the code is failing, please consult with Simon before further proceeding. +11. Type `git checkout main && git pull upstream main` and create a new branch called `precommit`. 12. Copy and paste the `.flake8` and `.pre-commit-config.yaml` files from `{{ cookiecutter.repo_name }}` to the top directory level. Cross-check with https://github.com/diffpy/diffpy.structure. -13. In a Conda env containing pre-commit, run `pre-commit run --all-files`. -14. Make a new PR before making any manual changes to files and have Simon merge it. If you have Pytest or unittests, ensure all tests are running locally. -15. Fix any errors and make periodic commits to address flake8 issues while ensuring tests pass. -16. Submit periodic PRs with each containing smaller commits to reduce cognitive overload for the reviewer (Simon). -17. Only proceed to the next section after all PRs relevant in the pre-commit workflow are addressed. +14. Run `pre-commit run --all-files`. Fix any spelling suggestions from Codespell. To ignore a specific word or line, add it under `.codespell/ignore_words.txt` or `.codespell/ignore_lines.txt`. To ignore specific file types, add the file extensions i.g. `*.gr` in `skip = line` under `[tool.codespell]` in `pyproject.toml`. Include explanations for each addition. +15. After the PR is merged, create a new branch called `flake8` +16. Fix flake8 errors manually: + - Tip 1: Start with easier error types to fix, such as line-lenghts and "module imported not used", etc. + - Tip 2: Submit periodic commits within a single PR. + - Tip 3: Create multiple PRs, each containing a specific theme (e.g., "Fix docstring line-length flake8 errors" using `flake8-lenght` branch, etc.) to reduce cognitive overload for the reviewer (Simon). + - Tip 4: Don't hesitate to reach out to group members who have contributed to this repository. They probably have seen those errors before! +18. Only proceed to the next section after addressing all PRs relevant to the pre-commit workflow. ### 2. Cookiecutter workflow From f62ccad2da45cd5d7a0e9f5c6e3d415d992fc72f Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Tue, 29 Oct 2024 08:22:55 -0400 Subject: [PATCH 2/6] Add instructions to fix flake8 after codespell --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7e5233f..2924f94 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,9 @@ For instance, there may be a more verbose description of what the package does, 11. Type `git checkout main && git pull upstream main` and create a new branch called `precommit`. 12. Copy and paste the `.flake8` and `.pre-commit-config.yaml` files from `{{ cookiecutter.repo_name }}` to the top directory level. Cross-check with https://github.com/diffpy/diffpy.structure. 14. Run `pre-commit run --all-files`. Fix any spelling suggestions from Codespell. To ignore a specific word or line, add it under `.codespell/ignore_words.txt` or `.codespell/ignore_lines.txt`. To ignore specific file types, add the file extensions i.g. `*.gr` in `skip = line` under `[tool.codespell]` in `pyproject.toml`. Include explanations for each addition. -15. After the PR is merged, create a new branch called `flake8` -16. Fix flake8 errors manually: +15. Create a PR to `main`. Mention in the PR that you need to address flake8 errors. +16. After the `precommit` branch has been merged, sync with `main` in Step 11, create a new branch called `flake8` +17. Fix flake8 errors manually: - Tip 1: Start with easier error types to fix, such as line-lenghts and "module imported not used", etc. - Tip 2: Submit periodic commits within a single PR. - Tip 3: Create multiple PRs, each containing a specific theme (e.g., "Fix docstring line-length flake8 errors" using `flake8-lenght` branch, etc.) to reduce cognitive overload for the reviewer (Simon). From 82dd692a8b759a9943edbff1edb012082d82a1e6 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Tue, 29 Oct 2024 08:25:31 -0400 Subject: [PATCH 3/6] Fix typo to length --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2924f94..cbaa746 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ For instance, there may be a more verbose description of what the package does, 17. Fix flake8 errors manually: - Tip 1: Start with easier error types to fix, such as line-lenghts and "module imported not used", etc. - Tip 2: Submit periodic commits within a single PR. - - Tip 3: Create multiple PRs, each containing a specific theme (e.g., "Fix docstring line-length flake8 errors" using `flake8-lenght` branch, etc.) to reduce cognitive overload for the reviewer (Simon). + - Tip 3: Create multiple PRs, each containing a specific theme (e.g., "Fix docstring line-length flake8 errors" using `flake8-length` branch, etc.) to reduce cognitive overload for the reviewer (Simon). - Tip 4: Don't hesitate to reach out to group members who have contributed to this repository. They probably have seen those errors before! 18. Only proceed to the next section after addressing all PRs relevant to the pre-commit workflow. From bf2777e2ed74094127374f040c21c73e18292f0d Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Tue, 29 Oct 2024 08:26:27 -0400 Subject: [PATCH 4/6] Add pip install in a single line --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index cbaa746..0f04e88 100644 --- a/README.md +++ b/README.md @@ -11,8 +11,7 @@ Create a new conda environment that includes the cookiecutter package by running ```bash # Download from PyPI -pip install cookiecutter -pip install black pre-commit +pip install cookiecutter black pre-commit ``` and follow the instructions provided below. From 3726fb250b71e24a3bc9d0b7a6655040402db543 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Tue, 29 Oct 2024 08:29:19 -0400 Subject: [PATCH 5/6] FIx typo to worfklow --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f04e88..d0cdf95 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ For instance, there may be a more verbose description of what the package does, 6. Create `pyproject.toml`. Copy and paste the `[tools.black]` and `[tool.codespell]` sections from `pyproject.toml` in the `{{ cookiecutter.repo_name }}` folder path. 7. Run `black src` (note: some of the older packages do not have an `src` directory, so you may have to run black on a different directory). 8. Commit the automatic changes by `black`. -9. Run `black .` and create a PR into `main`. Follow the group's GitHub worfklow tutorial on GitLab. +9. Run `black .` and create a PR into `main`. Follow the group's GitHub workflow tutorial on GitLab. 10. After the `black` branch has been merged, run pytest or unit tests to ensure all tests pass locally. If the code is failing, please consult with Simon before further proceeding. 11. Type `git checkout main && git pull upstream main` and create a new branch called `precommit`. 12. Copy and paste the `.flake8` and `.pre-commit-config.yaml` files from `{{ cookiecutter.repo_name }}` to the top directory level. Cross-check with https://github.com/diffpy/diffpy.structure. From 6669a298a8d77fa173a778d73f76c2b7c2b219bc Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Tue, 29 Oct 2024 23:29:21 -0400 Subject: [PATCH 6/6] Fix typo - branch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d0cdf95..5027c13 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ For instance, there may be a more verbose description of what the package does, 1. In your `dev` folder, fork and clone the package 2. `cd` into the top level directory of that project. -3. Type `git pull upstream main` to sync with the main brannch. +3. Type `git pull upstream main` to sync with the main branch. 4. Double check that no bug-fix etc. pull-requests are waiting to be merged. Check with Simon if not sure. 5. Create a new branch called `black`. 6. Create `pyproject.toml`. Copy and paste the `[tools.black]` and `[tool.codespell]` sections from `pyproject.toml` in the `{{ cookiecutter.repo_name }}` folder path.