Skip to content

Commit

Permalink
Add pre-commit configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
thenav56 committed Jun 14, 2024
1 parent 279227d commit dcacdab
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[flake8]
ignore = C901, W504
max-line-length = 125
exclude = .git,__pycache__,old,build,dist,*/migrations/*.py
extend-ignore = C901, W504, E203, E701
max-line-length = 130
exclude = .git,__pycache__,old,build,dist,*migrations*,*snapshots*
max-complexity = 10
per-file-ignores =
/**/tests/*_mock_data.py: E501
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Python lint check

on:
push:
branches:
- develop
pull_request:


jobs:
pre_commit_checks:
name: 🚴 Pre-Commit checks 🚴
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@main
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@main
with:
cache: 'poetry'
- run: poetry install
- uses: pre-commit/action@main
27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
default_language_version:
python: python3

# NOTE: Update in .flake8 pyproject.toml as well
exclude: |
(?x)^(
\.git|
__pycache__|
.*snap_test_.*\.py|
.+\/.+\/migrations\/.*
)
repos:
- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
18 changes: 15 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ reportMissingImports = true
reportMissingTypeStubs = false

[tool.black]
line-length = 125
py36 = true
line-length = 130
target-version = ['py39']
include = '\.pyi?$'
exclude = '''
/(
Expand All @@ -128,7 +128,19 @@ exclude = '''
| docs
)/
'''
extend-exclude = '^.*\b(migrations)\b.*$'
# NOTE: Update in .pre-commit-config.yaml as well
extend-exclude = "^.*\\b(migrations)\\b.*$ (__pycache__|.*snap_test_.*\\.py|.+/+.+/+migrations/+.*)"

[tool.isort]
profile = "black"
multi_line_output = 3
# NOTE: Update in .pre-commit-config.yaml as well
skip = [
"**/__pycache__",
"**/snap_test_*.py",
"**/migrations/*.py",
]


[build-system]
requires = ["poetry-core>=1.0.0"]
Expand Down
2 changes: 1 addition & 1 deletion utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def excel_to_python_date_format(excel_format):
# TODO: support all formats
# First replace excel's locale identifiers such as [$-409] by empty string
python_format = re.sub(
'(\[\\$-\d+\])', '', excel_format.upper() # noqa: W605
r'(\[\\$-\d+\])', '', excel_format.upper()
).\
replace('\\', '').\
replace('YYYY', '%Y').\
Expand Down

0 comments on commit dcacdab

Please sign in to comment.