Skip to content

Commit 2283b32

Browse files
authored
Merge pull request #27 from satyam-seth-learnings/v2
v2
2 parents 6bb328d + f872a12 commit 2283b32

28 files changed

+1296
-215
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MANAGE_PY_PATH=manage.py

.githooks/pre-push

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
echo "Running tests with coverage..."
4+
5+
coverage run manage.py test
6+
status=$?
7+
8+
if [ $status -ne 0 ]; then
9+
echo "❌ Tests failed. Push aborted."
10+
exit 1
11+
fi
12+
13+
coverage report --fail-under=85 # set your threshold
14+
if [ $? -ne 0 ]; then
15+
echo "❌ Coverage is below threshold. Push aborted."
16+
exit 1
17+
fi
18+
19+
echo "✅ Tests passed and coverage is acceptable. Proceeding with push."
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: 🚦 Basic Checks
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
quality-checks:
11+
name: Quality Checks
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: 📥 Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: 🐍 Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.12"
22+
23+
- name: 📦 Install dependencies
24+
run: pip install -r requirements.txt
25+
26+
- name: 🎨 Run black (formatting)
27+
run: black --check .
28+
29+
- name: 🧹 Run isort (import sorting)
30+
run: isort --check-only .
31+
32+
- name: 🧐 Run mypy (type checking)
33+
run: mypy .
34+
35+
- name: 🔍 Run pylint (linting)
36+
run: pylint **/*.py
37+
38+
- name: 🧪 Run tests with coverage
39+
run: coverage run manage.py test
40+
41+
- name: 📊 Generate coverage report (fail if <85%)
42+
run: coverage report --fail-under=85

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
.venv
2-
__pycache__
2+
__pycache__/
3+
*sqlite3
4+
.coverage
5+
htmlcov

.isort.cfg

Lines changed: 0 additions & 3 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.3.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
9+
- repo: https://github.com/psf/black
10+
rev: 25.1.0
11+
hooks:
12+
- id: black
13+
name: black to format python code
14+
15+
- repo: https://github.com/pycqa/isort
16+
rev: 6.0.1
17+
hooks:
18+
- id: isort
19+
name: isort to sort imports
20+
args:
21+
- --profile
22+
- black
23+
- --verbose
24+
- --skip-glob
25+
- "**/migrations/*.py"
26+
27+
- repo: https://github.com/pre-commit/mirrors-mypy
28+
rev: v1.17.0
29+
hooks:
30+
- id: mypy
31+
name: mypy to check types
32+
additional_dependencies:
33+
- django-jazzmin==3.0.1
34+
- django-stubs==5.2.2
35+
- djangorestframework==3.16.0
36+
- djangorestframework-stubs==3.16.1
37+
args: ["--config-file=mypy.ini"]
38+
39+
- repo: https://github.com/pycqa/pylint
40+
rev: v3.3.7
41+
hooks:
42+
- id: pylint
43+
name: pylint to check code quality
44+
entry: pylint
45+
language: python
46+
types: [python]
47+
args: ["--rcfile=.pylintrc"]
48+
additional_dependencies:
49+
- django-jazzmin==3.0.1
50+
- Django==5.2.4
51+
- pylint-django==2.6.1
52+
- djangorestframework==3.16.0

.pylintrc

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
# only in one or another interpreter, leading to false positives when analysed.
66
analyse-fallback-blocks=no
77

8+
# Clear in-memory caches upon conclusion of linting. Useful if running pylint
9+
# in a server-like mode.
10+
clear-cache-post-run=no
11+
812
# Load and enable all available extensions. Use --list-extensions to see a list
913
# all available extensions.
1014
#enable-all-extensions=
@@ -46,9 +50,9 @@ ignore=CVS
4650

4751
# Add files or directories matching the regular expressions patterns to the
4852
# ignore-list. The regex matches against paths and can be in Posix or Windows
49-
# format. Because '\' represents the directory delimiter on Windows systems, it
50-
# can't be used as an escape character.
51-
ignore-paths=
53+
# format. Because '\\' represents the directory delimiter on Windows systems,
54+
# it can't be used as an escape character.
55+
ignore-paths=.*/migrations
5256

5357
# Files or directories matching the regular expression patterns are skipped.
5458
# The regex matches against base names, not paths. The default value ignores
@@ -89,6 +93,12 @@ py-version=3.10
8993
# Discover python modules and packages in the file system subtree.
9094
recursive=no
9195

96+
# Add paths to the list of the source roots. Supports globbing patterns. The
97+
# source root is an absolute path or a path relative to the current working
98+
# directory used to determine a package namespace for modules located under the
99+
# source root.
100+
source-roots=
101+
92102
# When enabled, pylint would attempt to guess common misconfiguration and emit
93103
# user-friendly hints instead of false-positive error messages.
94104
suggestion-mode=yes
@@ -224,6 +234,10 @@ no-docstring-rgx=^_
224234
# These decorators are taken in consideration only for invalid-name.
225235
property-classes=abc.abstractproperty
226236

237+
# Regular expression matching correct type alias names. If left empty, type
238+
# alias names will be checked with the set naming style.
239+
#typealias-rgx=
240+
227241
# Regular expression matching correct type variable names. If left empty, type
228242
# variable names will be checked with the set naming style.
229243
#typevar-rgx=
@@ -246,21 +260,18 @@ check-protected-access-in-special-methods=no
246260
defining-attr-methods=__init__,
247261
__new__,
248262
setUp,
263+
asyncSetUp,
249264
__post_init__
250265

251266
# List of member names, which should be excluded from the protected access
252267
# warning.
253-
exclude-protected=_asdict,
254-
_fields,
255-
_replace,
256-
_source,
257-
_make
268+
exclude-protected=_asdict,_fields,_replace,_source,_make,os._exit
258269

259270
# List of valid names for the first argument in a class method.
260271
valid-classmethod-first-arg=cls
261272

262273
# List of valid names for the first argument in a metaclass class method.
263-
valid-metaclass-classmethod-first-arg=cls
274+
valid-metaclass-classmethod-first-arg=mcs
264275

265276

266277
[DESIGN]
@@ -307,8 +318,7 @@ min-public-methods=2
307318
[EXCEPTIONS]
308319

309320
# Exceptions that will emit a warning when caught.
310-
overgeneral-exceptions=BaseException,
311-
Exception
321+
overgeneral-exceptions=builtins.BaseException,builtins.Exception
312322

313323

314324
[FORMAT]
@@ -347,6 +357,9 @@ single-line-if-stmt=no
347357
# one.
348358
allow-any-import-level=
349359

360+
# Allow explicit reexports by alias from a package __init__.
361+
allow-reexport-from-package=no
362+
350363
# Allow wildcard imports from modules that define __all__.
351364
allow-wildcard-with-all=no
352365

@@ -416,14 +429,18 @@ disable=raw-checker-failed,
416429
useless-suppression,
417430
deprecated-pragma,
418431
use-symbolic-message-instead,
419-
import-outside-toplevel
420-
432+
use-implicit-booleaness-not-comparison-to-string,
433+
use-implicit-booleaness-not-comparison-to-zero,
434+
missing-module-docstring,
435+
import-outside-toplevel,
436+
fixme
437+
421438

422439
# Enable the message, report, category or checker with the given id(s). You can
423440
# either give multiple identifier separated by comma (,) or put this option
424441
# multiple time (only on the command line, not in the configuration file where
425442
# it should appear only once). See also the "--disable" option for examples.
426-
enable=c-extension-no-member
443+
enable=
427444

428445

429446
[METHOD_ARGS]
@@ -469,8 +486,9 @@ evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor
469486
# used to format the message information. See doc for all details.
470487
msg-template=
471488

472-
# Set the output format. Available formats are text, parseable, colorized, json
473-
# and msvs (visual studio). You can also give a reporter class, e.g.
489+
# Set the output format. Available formats are: text, parseable, colorized,
490+
# json2 (improved json format), json (old json format) and msvs (visual
491+
# studio). You can also give a reporter class, e.g.
474492
# mypackage.mymodule.MyReporterClass.
475493
#output-format=
476494

@@ -504,8 +522,8 @@ min-similarity-lines=4
504522
# Limits count of emitted suggestions for spelling mistakes.
505523
max-spelling-suggestions=4
506524

507-
# Spelling dictionary name. Available dictionaries: none. To make it work,
508-
# install the 'python-enchant' package.
525+
# Spelling dictionary name. No available dictionaries : You need to install
526+
# both the python package and the system dependency for enchant to work.
509527
spelling-dict=
510528

511529
# List of comma separated words that should be considered directives if they
@@ -622,4 +640,4 @@ redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io
622640

623641
# pylint_django configuration
624642
[pylint-django]
625-
django-settings-module=django_starter.settings
643+
django-settings-module=backend.settings

.vscode/extensions.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"recommendations": [
3+
"ms-python.python",
4+
"esbenp.prettier-vscode",
5+
"ms-python.black-formatter",
6+
"ms-python.isort",
7+
"ms-python.mypy-type-checker",
8+
"batisteo.vscode-django",
9+
"ms-python.pylint",
10+
"ms-python.debugpy",
11+
"ms-python.vscode-pylance",
12+
"yy0931.vscode-sqlite3-editor",
13+
"streetsidesoftware.code-spell-checker"
14+
]
15+
}

.vscode/settings.json

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
{
2-
"editor.formatOnSave": true,
3-
"editor.codeActionsOnSave": {
4-
"source.fixAll": true,
5-
"source.organizeImports": true,
6-
},
7-
"isort.args": [
8-
"skip_glob",
9-
"*/migrations/*",
10-
],
11-
"[python]": {
12-
"editor.defaultFormatter": "ms-python.black-formatter"
13-
},
14-
"python.linting.enabled": true,
15-
"python.linting.pylintEnabled": true,
16-
"python.linting.pylintArgs": [
17-
"--load-plugins",
18-
"pylint_django",
19-
"django-settings-module=django_starter.settings",
20-
],
21-
"python.linting.mypyEnabled": true,
2+
"editor.formatOnSave": true,
3+
"editor.codeActionsOnSave": {
4+
"source.fixAll": "explicit",
5+
"source.unusedImports": "explicit",
6+
"source.organizeImports": "explicit"
7+
},
8+
"editor.rulers": [100],
9+
"[json]": {
10+
"editor.defaultFormatter": "esbenp.prettier-vscode"
11+
},
12+
"[python]": {
13+
"editor.defaultFormatter": "ms-python.black-formatter"
14+
},
15+
"isort.args": ["--profile", "black", "--skip-glob", "*/migrations/*"],
16+
"python.testing.unittestEnabled": true,
17+
"python.testing.pytestEnabled": false,
18+
"python.testing.unittestArgs": ["-p", "*test*.py"]
2219
}

0 commit comments

Comments
 (0)