Skip to content

Commit

Permalink
Autoformat entire project, tidy up makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Hallett authored and phalt committed Feb 24, 2020
1 parent c7e10bd commit d5d55da
Show file tree
Hide file tree
Showing 17 changed files with 10,552 additions and 5,841 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
- checkout
- run:
name: Install deps
command: sudo make install && sudo make dev-install
command: sudo make dev-install
- run:
name: Linting
command: make lint
command: make format-check
- run:
name: Run tests
command: make test
Expand Down
33 changes: 21 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
install:
.PHONY: help

help:
@grep -E '^[a-zA-Z_-]+:.*?# .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?# "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'


install: # Install base requirements to run project
pip install -r requirements.txt

dev-install:
dev-install: # Install developer requirements + base requirements
pip install -r test-requirements.txt

lint:
pylint config data pokemon_v2 --load-plugins pylint_django

setup:
setup: # Set up the project database
python manage.py migrate --settings=config.local

wipe_db:
wipe_db: # Delete's the project database
rm -rf db.sqlite3

serve:
serve: # Run the project locally
python manage.py runserver --settings=config.local

test:
test: # Run tests
python manage.py test --settings=config.local

clean:
clean: # Remove any pyc files
find . -type f -name '*.pyc' -delete

migrate:
migrate: # run any outstanding migrations
python manage.py migrate --settings=config.local

shell:
shell: # Load a shell
python manage.py shell --settings=config.local

format: # Format the source code
black .

format-check: # Check the source code has been formatted
black . --check
18 changes: 8 additions & 10 deletions config/docker-compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from .settings import *

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'pokeapi',
'USER': 'ash',
'PASSWORD': 'pokemon',
'HOST': 'db',
'PORT': 5432,
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": "pokeapi",
"USER": "ash",
"PASSWORD": "pokemon",
"HOST": "db",
"PORT": 5432,
}
}

Expand All @@ -17,9 +17,7 @@
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://cache:6379/1",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
"OPTIONS": {"CLIENT_CLASS": "django_redis.client.DefaultClient",},
}
}

Expand Down
18 changes: 8 additions & 10 deletions config/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from .settings import *

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'pokeapi',
'USER': 'ash',
'PASSWORD': 'pokemon',
'HOST': 'localhost',
'PORT': '',
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": "pokeapi",
"USER": "ash",
"PASSWORD": "pokemon",
"HOST": "localhost",
"PORT": "",
}
}

Expand All @@ -17,9 +17,7 @@
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/1",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
"OPTIONS": {"CLIENT_CLASS": "django_redis.client.DefaultClient",},
}
}

Expand Down
12 changes: 4 additions & 8 deletions config/local.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
from .settings import *

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(PROJECT_ROOT, 'db.sqlite3'),
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(PROJECT_ROOT, "db.sqlite3"),
}
}

CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
CACHES = {"default": {"BACKEND": "django.core.cache.backends.dummy.DummyCache",}}

DEBUG = True
TASTYPIE_FULL_DEBUG = True
107 changes: 47 additions & 60 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,21 @@

TEMPLATE_DEBUG = DEBUG

ADMINS = (
('Paul Hallett', '[email protected]'),
)
ADMINS = (("Paul Hallett", "[email protected]"),)

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

MANAGERS = ADMINS

BASE_URL = 'http://pokeapi.co'
BASE_URL = "http://pokeapi.co"

# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ['.pokeapi.co', 'localhost', '127.0.0.1']
ALLOWED_HOSTS = [".pokeapi.co", "localhost", "127.0.0.1"]

TIME_ZONE = 'Europe/London'
TIME_ZONE = "Europe/London"

LANGUAGE_CODE = 'en-gb'
LANGUAGE_CODE = "en-gb"

SITE_ID = 1

Expand All @@ -40,91 +38,80 @@
USE_TZ = True

# Explicitly define test runner to avoid warning messages on test execution
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
TEST_RUNNER = "django.test.runner.DiscoverRunner"

SECRET_KEY = '4nksdock439320df*(^x2_scm-o$*py3e@-awu-n^hipkm%2l$sw$&2l#'
SECRET_KEY = "4nksdock439320df*(^x2_scm-o$*py3e@-awu-n^hipkm%2l$sw$&2l#"

MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

ROOT_URLCONF = 'config.urls'
ROOT_URLCONF = "config.urls"

WSGI_APPLICATION = 'config.wsgi.application'
WSGI_APPLICATION = "config.wsgi.application"

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'pokeapi_co_db',
'USER': 'root',
'PASSWORD': 'pokeapi',
'HOST': 'localhost',
'PORT': '',
'CONN_MAX_AGE': 30
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": "pokeapi_co_db",
"USER": "root",
"PASSWORD": "pokeapi",
"HOST": "localhost",
"PORT": "",
"CONN_MAX_AGE": 30,
}
}

CACHES = {
"default": {
"BACKEND": "django_redis.cache.RedisCache",
"LOCATION": "redis://127.0.0.1:6379/1",
"OPTIONS": {
"CLIENT_CLASS": "django_redis.client.DefaultClient",
}
"OPTIONS": {"CLIENT_CLASS": "django_redis.client.DefaultClient",},
}
}

SECRET_KEY = os.environ.get(
'SECRET_KEY',
'ubx+22!jbo(^x2_scm-o$*py3e@-awu-n^hipkm%2l$sw$&2l#')
"SECRET_KEY", "ubx+22!jbo(^x2_scm-o$*py3e@-awu-n^hipkm%2l$sw$&2l#"
)

CUSTOM_APPS = (
'tastypie',
'pokemon_v2',
"tastypie",
"pokemon_v2",
)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.humanize',
'corsheaders',
'rest_framework',
'cachalot'
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.sites",
"django.contrib.admin",
"django.contrib.humanize",
"corsheaders",
"rest_framework",
"cachalot",
) + CUSTOM_APPS


API_LIMIT_PER_PAGE = 1

TASTYPIE_DEFAULT_FORMATS = ['json']
TASTYPIE_DEFAULT_FORMATS = ["json"]

CORS_ORIGIN_ALLOW_ALL = True

CORS_ALLOW_METHODS = (
'GET'
)
CORS_ALLOW_METHODS = "GET"

CORS_URLS_REGEX = r'^/api/.*$'
CORS_URLS_REGEX = r"^/api/.*$"

REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'drf_ujson.renderers.UJSONRenderer',
),
'DEFAULT_PARSER_CLASSES': (
'drf_ujson.renderers.UJSONRenderer',
),

'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',

'PAGE_SIZE': 20,

'PAGINATE_BY': 20
"DEFAULT_RENDERER_CLASSES": ("drf_ujson.renderers.UJSONRenderer",),
"DEFAULT_PARSER_CLASSES": ("drf_ujson.renderers.UJSONRenderer",),
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination",
"PAGE_SIZE": 20,
"PAGINATE_BY": 20,
}
2 changes: 1 addition & 1 deletion config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
# pylint: disable=invalid-name

urlpatterns = [
url(r'^', include(pokemon_v2_urls)),
url(r"^", include(pokemon_v2_urls)),
]
Loading

0 comments on commit d5d55da

Please sign in to comment.