Skip to content

Commit

Permalink
Fix #151 setup pre-commit and black (#173)
Browse files Browse the repository at this point in the history
* Add pre-commit to makefile

* Fix #151 setup pre-commit and black
  • Loading branch information
rochacbruno authored Apr 22, 2019
1 parent 8a2ae3d commit e485217
Show file tree
Hide file tree
Showing 123 changed files with 2,543 additions and 2,467 deletions.
7 changes: 5 additions & 2 deletions .pep8speaks.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
scanner:
diff_only: True # If False, the entire file touched by the Pull Request is scanned for errors. If True, only the diff is scanned.
linter: flake8 # Other option is flake8

flake8: # Same as scanner.linter value. Other option is flake8
max-line-length: 79 # Default is 79 in PEP 8
ignore: # Errors and warnings to ignore
- F841 # (local variable assigned but never used, useful for debugging on exception)
- W504 # (line break after binary operator, I prefer to put `and|or` at the end)
- W503 # (line break before binary operator, black prefer to put `and|or` at the end)
- F403 # (star import `from foo import *` often used in __init__ files)
- E401 # (multiple imports on one line)

- F401 # (not used import)
- E402 # (Imports not on top)

# no_blank_comment: True # If True, no comment is made on PR without any errors.
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
exclude: docs
repos:
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.4.0
hooks:
- id: reorder-python-imports
language_version: python3
args: [--py3-plus]
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
args: [--line-length=79]
language_version: python3.7
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
hooks:
- id: trailing-whitespace
language_version: python3
- id: end-of-file-fixer
language_version: python3
- id: check-yaml
language_version: python3
- id: check-merge-conflict
language_version: python3
- id: debug-statements
language_version: python3
- id: fix-encoding-pragma
language_version: python3
args: [--remove]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.0
hooks:
- id: flake8
args: ['--ignore=F403,W504,W503,F841,E401,F401,E402']
language_version: python3
30 changes: 25 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
SHELL := /bin/bash
.PHONY: test install pep8 publish dist clean docs test_examples test_vault test_redis
.PHONY: all clean dist docs install pep8 publish run-pre-commit run-tox setup-pre-commit test test_examples test_only test_redis test_vault help coverage-report

help:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'

all: clean install run-pre-commit test test_examples coverage-report

test_examples:
@echo '############### Chdir to example directory ###############'
Expand Down Expand Up @@ -37,7 +42,7 @@ test_examples:
cd example/project_root/;pwd;rm -rf /tmp/dynaconf_project_root_test/settings.py;mkdir -p /tmp/dynaconf_project_root_test/;echo "MESSAGE = 'Hello from tmp'" > /tmp/dynaconf_project_root_test/settings.py;python app.py;rm -rf /tmp/dynaconf_project_root_test/
cd example/settings_file/;pwd;rm -rf /tmp/settings_file_test/settings.py;mkdir -p /tmp/settings_file_test/;echo "MESSAGE = 'Hello from tmp'" > /tmp/settings_file_test/settings.py;python app.py;rm -rf /tmp/settings_file_test/
cd example/configure/;pwd;rm -rf /tmp/configure_test/settings.py;mkdir -p /tmp/configure_test/;echo "MESSAGE = 'Hello from tmp'" > /tmp/configure_test/settings.py;python app.py;rm -rf /tmp/configure_test/

@echo '############### Calling from outer folder ###############'
python example/common/program.py
python example/common-encoding/program.py
Expand Down Expand Up @@ -92,25 +97,36 @@ test_only:
py.test --boxed -v --cov-config .coveragerc --cov=dynaconf -l --tb=short --maxfail=1 tests/
coverage xml

coverage-report:
coverage report --fail-under=100

test: pep8 test_only

install:
pip install --upgrade pip
python setup.py develop
pip install -r requirements_dev.txt
make setup-pre-commit

setup-pre-commit:
pre-commit install
pre-commit install-hooks

run-pre-commit:
pre-commit run --files $$(find -regex '.*\.\(py\|yaml\|yml\)') -v

pep8:
# Flake8 ignores
# Flake8 ignores
# F841 (local variable assigned but never used, useful for debugging on exception)
# W504 (line break after binary operator, I prefer to put `and|or` at the end)
# F403 (star import `from foo import *` often used in __init__ files)
flake8 dynaconf --ignore=F403,W504,F841
flake8 dynaconf --ignore=F403,W504,W503,F841,E401,F401,E402

dist: clean
@python setup.py sdist bdist_wheel

publish:
@tox
make run-tox
@twine upload dist/*

clean:
Expand All @@ -128,3 +144,7 @@ clean:
docs:
rm -rf docs/_build
@cd docs;make html

run-tox:
tox -r
rm -rf .tox
32 changes: 30 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,28 @@ trigger:

jobs:

- job: 'Adequacy'
variables:
DEBUG_LEVEL_FOR_DYNACONF: DEBUG
pool:
vmImage: 'Ubuntu-16.04'
strategy:
matrix:
Python37:
python.version: '3.7'
maxParallel: 4

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
architecture: 'x64'

- bash: make clean install run-pre-commit
displayName: 'Adequacy Tests'

- job: 'LinuxInstall'
dependsOn: Adequacy
variables:
DEBUG_LEVEL_FOR_DYNACONF: DEBUG
pool:
Expand Down Expand Up @@ -38,7 +59,8 @@ jobs:
dynaconf --version
displayName: 'Install and test cli'
- job: 'LinuxUnit'
- job: 'LinuxUnit'
dependsOn: Adequacy
variables:
- group: codecov
pool:
Expand Down Expand Up @@ -76,6 +98,7 @@ jobs:
condition: succeededOrFailed()

- job: 'LinuxFunctional'
dependsOn: Adequacy
variables:
DEBUG_LEVEL_FOR_DYNACONF: DEBUG
pool:
Expand All @@ -101,6 +124,7 @@ jobs:
displayName: 'Functional tests for examples and frameworks'

- job: 'Redis'
dependsOn: Adequacy
variables:
REDIS_ENABLED_FOR_DYNACONF: true
DEBUG_LEVEL_FOR_DYNACONF: DEBUG
Expand Down Expand Up @@ -131,6 +155,7 @@ jobs:
displayName: 'Functional test for redis'

- job: 'Vault'
dependsOn: Adequacy
variables:
VAULT_ENABLED_FOR_DYNACONF: true
VAULT_TOKEN_FOR_DYNACONF: myroot
Expand Down Expand Up @@ -162,6 +187,7 @@ jobs:
displayName: 'Functional test for vault'

- job: 'WindowsUnit'
dependsOn: Adequacy
variables:
DEBUG_LEVEL_FOR_DYNACONF: DEBUG
pool:
Expand All @@ -175,7 +201,7 @@ jobs:
inputs:
versionSpec: '$(python.version)'
architecture: 'x64'

- script: |
python -m pip install --upgrade pip
python -m pip install -r requirements_dev.txt
Expand All @@ -189,6 +215,7 @@ jobs:
condition: succeededOrFailed()

- job: 'WindowsInstall'
dependsOn: Adequacy
variables:
DEBUG_LEVEL_FOR_DYNACONF: DEBUG
pool:
Expand All @@ -213,6 +240,7 @@ jobs:
displayName: 'Install and test cli'
- job: 'WindowsFunctional'
dependsOn: Adequacy
variables:
DEBUG_LEVEL_FOR_DYNACONF: DEBUG
DJANGO_SETTINGS_MODULE: foo.settings
Expand Down
15 changes: 10 additions & 5 deletions dynaconf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# coding: utf-8
from dynaconf.base import LazySettings
from dynaconf.validator import Validator, ValidationError
from dynaconf.contrib import FlaskDynaconf, DjangoDynaconf
from dynaconf.contrib import DjangoDynaconf
from dynaconf.contrib import FlaskDynaconf
from dynaconf.validator import ValidationError
from dynaconf.validator import Validator

settings = LazySettings()

__all__ = [
'settings', 'LazySettings', 'Validator',
'FlaskDynaconf', 'ValidationError', 'DjangoDynaconf'
"settings",
"LazySettings",
"Validator",
"FlaskDynaconf",
"ValidationError",
"DjangoDynaconf",
]
Loading

0 comments on commit e485217

Please sign in to comment.