Skip to content

Commit

Permalink
Merge pull request #175 from MITLibraries/IN-894-update-config-and-li…
Browse files Browse the repository at this point in the history
…nting

Update project to python 3.11 and new linting
  • Loading branch information
ghukill committed Oct 23, 2023
2 parents 5ad2f24 + 4e946ae commit 30a9fc6
Show file tree
Hide file tree
Showing 20 changed files with 815 additions and 829 deletions.
29 changes: 26 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
Expand Down Expand Up @@ -50,6 +49,8 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
cover/
coverage/

# Translations
*.mo
Expand All @@ -72,6 +73,7 @@ instance/
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
Expand All @@ -82,6 +84,8 @@ profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
Expand All @@ -91,6 +95,13 @@ ipython_config.py
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

Expand Down Expand Up @@ -128,6 +139,18 @@ dmypy.json
# Pyre type checker
.pyre/

# Mac
# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# IDEs
.idea/
.vscode/

# Local directories
output/

*.DS_Store
# MacOS files
.DS_Store
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
coverage/

# Translations
*.mo
Expand Down Expand Up @@ -129,5 +130,8 @@ dmypy.json
.pyre/

# Mac
.DS_Store

*.DS_Store
# VSCode
.vscode/
.idea/
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
language: system
pass_filenames: true
types: ["python"]
exclude: "tests/"
- 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
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.10.10
3.11.4
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM public.ecr.aws/lambda/python:3.10
FROM public.ecr.aws/lambda/python:3.11

# Copy function code
COPY . ${LAMBDA_TASK_ROOT}/
Expand Down
26 changes: 17 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ help: ## Print this message
### Dependency commands ###
install: ## Install dependencies
pipenv install --dev
pipenv run pre-commit install

update: install ## Update all Python dependencies
update: install # update all Python dependencies
pipenv clean
pipenv update --dev
pipenv requirements

### Test commands ###
test: ## Run tests and print a coverage report
Expand All @@ -28,25 +28,33 @@ test: ## Run tests and print a coverage report
coveralls: test
pipenv run coverage lcov -o ./coverage/lcov.info

### Code quality and safety commands ###
lint: bandit black mypy pylama safety ## Run linting, code quality, and safety checks
## ---- Code quality and safety commands ---- ##

bandit:
pipenv run bandit -r lambdas
# linting commands
lint: black mypy ruff safety

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

mypy:
pipenv run mypy lambdas
pipenv run mypy .

pylama:
pipenv run pylama --options setup.cfg
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 Dev environment ###
dist-dev: ## Build docker container (intended for developer-based manual build)
docker build --platform linux/amd64 \
Expand Down
7 changes: 4 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ boto3 = "*"
smart-open = "*"

[dev-packages]
bandit = "*"
black = "*"
boto3-stubs = {extras = ["essential"], version = "*"}
coverage = "*"
freezegun = "*"
moto = "*"
mypy = "*"
pylama = {extras = ["all"], version = "*"}
pre-commit = "*"
pytest = "*"
ruff = "*"

[requires]
python_version = "3.10"
python_version = "3.11"
Loading

0 comments on commit 30a9fc6

Please sign in to comment.