Extending pre-commit functionality and linting
See original GitHub issueIs your feature request related to a current problem? Please describe. no
Describe proposed solution including more git pre-commit hooks can increase code clarity and prevent bugs.
Describe potential alternatives N/A
Additional context
- flake8 can enforce code formatting not automatically fixed by black
- the pre-commit-hook repo can fix many basic annoyance
- pyupgrade can update deprecated methods
- mypy is a static typing
- isort or reorder_python_imports improves imports
example
repos:
- repo: https://github.com/psf/black
rev: 21.12b0
hooks:
- id: black
language_version: python3.7
args: [--safe, "--line-length", "100"]
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
language_version: python3
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-added-large-files
- id: check-builtin-literals
- id: check-json
- id: check-shebang-scripts-are-executable
- id: check-xml
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: mixed-line-ending
- id: check-ast
- id: pretty-format-json
args: ['--autofix', '--no-sort-keys']
- repo: https://github.com/asottile/pyupgrade
rev: v2.29.1
hooks:
- id: pyupgrade
args: ['--py37-plus']
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910-1
hooks:
- id: mypy
args: [--ignore-missing-imports]
additional_dependencies: [types-PyYAML, types-requests, types-PyMySQL]
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.6.0
hooks:
- id: reorder-python-imports
args: [--py37-plus]
#- repo: https://github.com/pre-commit/mirrors-isort
# rev: v5.9.3
# hooks:
# - id: isort
# args: [-e, "--profile", "black"]
I would be willing to work on it but want to know if it would be merged
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Automatically format and lint code with pre-commit - Interrupt
This article provides some background and guidelines for using pre-commit to automatically format and lint C-language firmware codebases.
Read more >Supported hooks - pre-commit
cheetah-reorder-imports - This hook reorders imports in cheetah files. cheetah-flake - Lint cheetah code using flake8 and some other checks.
Read more >Code quality: pre-commit linting - JavaScript in Plain English
The main purpose of the instrument is to format the code in a visually nice manner. It aligns all spaces and indents providing...
Read more >Enforcing Coding Conventions with Husky Pre-commit Hooks
Pretend we have code with bad format. If we try to commit, our hook firstly will format the code, then linter will say...
Read more >Lint Staged With Husky for Pre-commit Validations - YouTube
Learn how to use lint staged with husky to implement linting and formatting your code with Prettier and Eslint on pre-commit.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@tomasvanpottelbergh I’m going to work on adding isort
We could maybe enforce 120. WDYT @tomasvanpottelbergh ?