Skip to content

Comments

STY: Configure linters and apply style cleanup#11

Merged
technic960183 merged 10 commits intomainfrom
fix_style
May 5, 2025
Merged

STY: Configure linters and apply style cleanup#11
technic960183 merged 10 commits intomainfrom
fix_style

Conversation

@technic960183
Copy link
Owner

@technic960183 technic960183 commented May 3, 2025

Purpose

Configure and apply code style checks using MegaLinter (initial setup in PR #10). This PR refines multiple linter configurations and updates the codebase to comply with their rules.

Change of Linter Configuration

  • Configure various linters via .mega-linter.yml, .isort.cfg, .cspell.json, etc.
  • Disable all RST related linters, because they can't work with directives from Sphinx.
  • Disable pyright, because I fail to install dependency to its virtual environment and it won't work well.
  • Disable two prettier, because they don't give effective message in non-fix mode.
  • Limit enabled repository related linters to: git_diff, gitleak, and trivy. Others are redundant or are not useful for this project.
  • Disable error from jscpd and mypy.

Change of the Codebase

  • Fix whitespace, blank lines, and line length issues (flake8)
  • Apply best practices for Python syntax (flake8, ruff)
  • Add or refine static type annotations (mypy, pyright)
  • Clean and sort imports consistently (isort, ruff)
  • Comment out outdated or invalid unit tests (ruff, pylint)
  • Formatting improvements (black)
  • Fix typos (cspell)
  • Rename docs/source/dev/pycorrelator.rst ->docs/source/dev/spherimatch.rst. (cspell) What a great catch!

Note

  • These changes were made iteratively: fix lint issue → adjust config → re-run linters via GitHub Actions → repeat → rebase to squash the commits at the end.
  • The goal is to establish consistent coding style and improve maintainability with no change to logic or behavior.
  • I have not decided yet if I want to use black style for the whole project.

@github-actions
Copy link

github-actions bot commented May 3, 2025

🦙 MegaLinter status: ⚠️ WARNING

Descriptor Linter Files Fixed Errors Warnings Elapsed time
⚠️ COPYPASTE jscpd yes 7 no 1.65s
✅ JSON jsonlint 1 0 0 0.16s
✅ JSON v8r 1 0 0 2.14s
✅ MARKDOWN markdownlint 1 0 0 0.61s
✅ MARKDOWN markdown-link-check 1 0 0 1.41s
✅ MARKDOWN markdown-table-formatter 1 0 0 0.26s
✅ PYTHON bandit 18 0 0 1.81s
⚠️ PYTHON black 18 1 0 2.79s
✅ PYTHON flake8 18 0 0 1.15s
✅ PYTHON isort 18 0 0 0.25s
⚠️ PYTHON mypy 18 2 0 5.79s
✅ PYTHON pylint 18 0 0 21.53s
✅ PYTHON ruff 18 0 0 0.02s
✅ SPELL cspell 31 0 0 4.25s
✅ SPELL lychee 12 0 0 0.58s
✅ YAML v8r 4 0 0 5.86s
✅ YAML yamllint 4 0 0 0.43s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

@technic960183 technic960183 force-pushed the fix_style branch 3 times, most recently from b486e48 to d49cbba Compare May 5, 2025 14:16
Thanks: mypy, pyright
Thanks: isort, ruff

Also make the relative import to absolute import for unittest files.
So the unittest loader can load them correctly.
- `from .test_fof import generate_celestial_grid`
+ `from tests.test_fof import generate_celestial_grid`
Thanks: black
I have not decided yet if I want to use `black` style for the whole
project.
Thanks: cspell
Thanks the `megalinter` team to make `cspell` able to check the
filename. This lead me to the discovery that I forgot to rename this rst
file when I renamed the package.
@technic960183 technic960183 merged commit 1583e1c into main May 5, 2025
1 check passed
@technic960183 technic960183 deleted the fix_style branch May 5, 2025 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant