Skip to content

Commit

Permalink
In 885 app stabilization linters (#85)
Browse files Browse the repository at this point in the history
* Apply black, mypy, ruff, safety
* Add pyproject.toml
* Add test to verify non-configured DatabaseEngine
result in 'AttributeError' when using callable
* Add Make command to apply changes to resolve linting issues
* Add pre-commit hooks
* Add dependabot
* Rerun fresh install of dependencies


Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/IN-885
  • Loading branch information
jonavellecuerdo committed Aug 14, 2023
1 parent 5fb5706 commit d0e24de
Show file tree
Hide file tree
Showing 19 changed files with 864 additions and 415 deletions.
28 changes: 28 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

# Maintain dependencies for application
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "weekly"
reviewers:
- "MITLibraries/dataeng"

# Maintain dependencies for Docker
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
reviewers:
- "MITLibraries/dataeng"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ tests/db/
vendor/
.env
*.log
output/
output/
.vscode/
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
default_language_version:
python: python3.11 # set for project python version
repos:
- repo: local
hooks:
- id: black-apply
name: black-apply
entry: pipenv run black
language: system
pass_filenames: true
types: ["python"]
- id: mypy
name: mypy
entry: pipenv run mypy
exclude: tests/
language: system
pass_filenames: true
types: ["python"]
- id: ruff-apply
name: ruff-apply
entry: pipenv run ruff check --fix
language: system
pass_filenames: true
types: ["python"]
- id: safety
name: safety
entry: pipenv check
language: system
pass_filenames: false
27 changes: 25 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ DATETIME:=$(shell date -u +%Y%m%dT%H%M%SZ)

install: # install python dependencies
pipenv install --dev
pipenv run pre-commit install

update: install # update all python dependencies
pipenv clean
Expand All @@ -38,8 +39,30 @@ coveralls: test

## ---- Code quality and safety commands ---- ##

lint: ## run linters
pipenv run flake8 carbon
# linting commands
lint: black mypy ruff safety

black:
pipenv run black --check --diff .

mypy:
pipenv run mypy .

ruff:
pipenv run ruff check .

safety:
pipenv check
pipenv verify

# apply changes to resolve any linting errors
lint-apply: black-apply ruff-apply

black-apply:
pipenv run black .

ruff-apply:
pipenv run ruff check --fix .

## ---- Terraform-generated Developer Deploy Commands for Dev1 environment ---- ##

Expand Down
14 changes: 11 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,28 @@ verify_ssl = true
name = "pypi"

[dev-packages]
black = "*"
boto3-stubs = {extras = ["essential"], version = "*"}
coveralls = "*"
lxml-stubs = "*"
mypy = "*"
pre-commit = "*"
pytest = "*"
pytest-cov = "*"
PyYAML = "*"
pyftpdlib = "*"
pyopenssl = "*"
flake8 = "*"
ruff = "*"
types-setuptools = "*"


[packages]
boto3 = "*"
click = "*"
lxml = "*"
SQLAlchemy = "*"
oracledb = "*"
"boto3" = "*"
SQLAlchemy = "*"

sentry-sdk = "*"

[requires]
Expand Down

0 comments on commit d0e24de

Please sign in to comment.