Skip to content

Commit

Permalink
Merge pull request #3232 from SEED-platform/Add-pre-commits
Browse files Browse the repository at this point in the history
Add pre commits
  • Loading branch information
nllong committed May 8, 2022
2 parents 5852cbf + ccc175a commit 3b8e88b
Show file tree
Hide file tree
Showing 469 changed files with 7,682 additions and 8,032 deletions.
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ languages:
# http://docs.codeclimate.com/article/166-excluding-files-folders
#
exclude_paths:
- "seed/static/vendors/*"
- "seed/static/vendors/*"
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
*.jpg binary
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
tox_env: [flake8, docs, mypy]
tox_env: [docs, precommit, mypy]
steps:
-
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
.cache
.env
.hypothesis
.idea
.project
.pydevproject
Expand Down Expand Up @@ -88,4 +89,3 @@ docker-compose.*.yml

# generated files
/auto*.csv

31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
exclude: |
(?x)(
.*/migrations
)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
hooks:
- id: trailing-whitespace
- id: check-added-large-files
args: ['--maxkb=2000']
- id: check-ast
- id: check-json
- id: check-merge-conflict
- id: check-xml
- id: check-yaml
exclude: .*/templates
- id: debug-statements
- id: end-of-file-fixer
# - id: requirements-txt-fixer
- id: flake8
args: ['--max-line-length=140'] # default of Black
- id: mixed-line-ending
- id: pretty-format-json
args: ['--autofix', '--no-sort-keys', '--no-ensure-ascii']
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.4
hooks:
- id: isort
args: ['-m 3'] # vertical hanging
2 changes: 1 addition & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Building Energy
Open Green Building Society
- Ryan McCuaig (https://github.com/rgm/)

---
---
Devetry
- Adrian Lara (https://github.com/adrian-lara)
- Daniel Bressan (https://github.com/danielbressan)
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Closed Issues and Features (Total: 7):
Date Range: 09/28/21 - 11/04/21

Closed Issues and Features (Total: 36):
- Feature [#2524]( https://github.com/SEED-platform/seed/issues/2524 ), Export CSV -- Need a status bar or spinner or something to indicate that program is still working
- Feature [#2524]( https://github.com/SEED-platform/seed/issues/2524 ), Export CSV -- Need a status bar or spinner or something to indicate that program is still working
- Feature [#2557]( https://github.com/SEED-platform/seed/issues/2557 ), Create Analyses Section
- Fixed [#2587]( https://github.com/SEED-platform/seed/issues/2587 ), Add admin tools
- Fixed [#2651]( https://github.com/SEED-platform/seed/issues/2651 ), Analysis and Merge/Link Matches on Property Detail view on production server (and shouldn't be)
Expand Down Expand Up @@ -149,7 +149,7 @@ Closed Issues and Features (Total: 65):
- Maintenance [#2379]( https://github.com/SEED-platform/seed/issues/2379 ), Refactor perms for several API v3 views
- Fixed [#2433]( https://github.com/SEED-platform/seed/issues/2433 ), Upgrade dependencies, python 3.9
- Fixed [#2490]( https://github.com/SEED-platform/seed/issues/2490 ), Update Python dependencies to re-enable Python package installation
- Feature [#2511]( https://github.com/SEED-platform/seed/issues/2511 ), Inventory List: Hover over the notes icon and see the notes
- Feature [#2511]( https://github.com/SEED-platform/seed/issues/2511 ), Inventory List: Hover over the notes icon and see the notes
- Feature [#2535]( https://github.com/SEED-platform/seed/issues/2535 ), BSyncr Analysis results should render image results when available
- Fixed [#2574]( https://github.com/SEED-platform/seed/issues/2574 ), `eui` and `area` columns don't respect filter syntax
- Fixed [#2654]( https://github.com/SEED-platform/seed/issues/2654 ), Report on user adoption
Expand Down
6 changes: 3 additions & 3 deletions bin/check_compressed.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved.
:author
"""
#!/usr/bin/env python
import sys
# !/usr/bin/env python
# encoding: utf-8
from subprocess import call

Expand All @@ -12,5 +13,4 @@
else:
print("compression failed")

import sys
sys.exit(c)
1 change: 0 additions & 1 deletion charts/seed/templates/web-celery-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ spec:
ports:
- port: 5432
targetPort: 5432

2 changes: 1 addition & 1 deletion config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved.
:author
"""
2 changes: 1 addition & 1 deletion config/settings/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved.
:author
"""
10 changes: 3 additions & 7 deletions config/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@
:copyright (c) 2014 - 2022, The Regents of the University of California,
through Lawrence Berkeley National Laboratory (subject to receipt of any
required approvals from the U.S. Department of Energy) and contributors.
All rights reserved. # NOQA
All rights reserved.
:author
"""
from __future__ import absolute_import

import os

from kombu import Exchange, Queue
from django.utils.translation import gettext_lazy as _
from kombu.serialization import register

from seed.serializers.celery import CeleryDatetimeSerializer

from django.utils.translation import gettext_lazy as _

BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

SESSION_COOKIE_DOMAIN = None
Expand Down Expand Up @@ -127,7 +124,6 @@
}



# Apps with tables created by migrations, but which 3rd-party apps depend on.
# Internal apps can resolve this via South's depends_on.
HIGH_DEPENDENCY_APPS = ('seed.landing',) # 'landing' contains SEEDUser
Expand Down Expand Up @@ -325,7 +321,7 @@
BSYNCR_SERVER_PORT = os.environ.get('BSYNCR_SERVER_PORT', '80')

# LBNL's BETTER tool host location
BETTER_HOST = os.environ.get('BETTER_HOST', 'https://better.lbl.gov')
BETTER_HOST = os.environ.get('BETTER_HOST', 'https://better.lbl.gov')

# Google reCAPTCHA env variable for self-registration. SITE_KEY defaults
# to the key registered for SEED. Override it needing to test.
Expand Down
13 changes: 6 additions & 7 deletions config/settings/dev.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved.
:author
"""
from __future__ import absolute_import

import sys
# use importlib module to find the local_untracked file rather than a hard-coded path
import importlib
import os

from config.settings.common import * # noqa
from kombu import Exchange, Queue
from django.conf import settings

DEBUG = True
compress = False
Expand All @@ -32,7 +33,7 @@
},
}

MIDDLEWARE = ('seed.utils.nocache.DisableClientSideCachingMiddleware',) + MIDDLEWARE
MIDDLEWARE = ('seed.utils.nocache.DisableClientSideCachingMiddleware',) + MIDDLEWARE # noqa F405

LOGGING = {
'version': 1,
Expand Down Expand Up @@ -75,8 +76,6 @@

ALLOWED_HOSTS = ['*']

# use importlib module to find the local_untracked file rather than a hard-coded path
import importlib

local_untracked_spec = importlib.util.find_spec('config.settings.local_untracked')
if local_untracked_spec is None:
Expand Down
23 changes: 13 additions & 10 deletions config/settings/docker.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved.
:author nicholas.long@nrel.gov
File contains settings needed to run SEED with docker
"""
from __future__ import absolute_import

import os

from config.settings.common import * # noqa
from kombu import Exchange, Queue

# Gather all the settings from the docker environment variables
ENV_VARS = ['POSTGRES_DB', 'POSTGRES_PORT', 'POSTGRES_USER', 'POSTGRES_PASSWORD', ]
Expand Down Expand Up @@ -42,8 +45,8 @@
# By default we are using SES as our email client. If you would like to use
# another backend (e.g. SMTP), then please update this model to support both and
# create a pull request.
EMAIL_BACKEND = (DJANGO_EMAIL_BACKEND if 'DJANGO_EMAIL_BACKEND' in os.environ else "django_ses.SESBackend")
DEFAULT_FROM_EMAIL = SERVER_EMAIL
EMAIL_BACKEND = (DJANGO_EMAIL_BACKEND if 'DJANGO_EMAIL_BACKEND' in os.environ else "django_ses.SESBackend") # noqa F405
DEFAULT_FROM_EMAIL = SERVER_EMAIL # noqa F405
POST_OFFICE = {
'BACKENDS': {
'default': EMAIL_BACKEND,
Expand All @@ -56,11 +59,11 @@
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': POSTGRES_DB,
'USER': POSTGRES_USER,
'PASSWORD': POSTGRES_PASSWORD,
'NAME': POSTGRES_DB, # noqa F405
'USER': POSTGRES_USER, # noqa F405
'PASSWORD': POSTGRES_PASSWORD, # noqa F405
'HOST': "db-postgres",
'PORT': POSTGRES_PORT,
'PORT': POSTGRES_PORT, # noqa F405
}
}

Expand All @@ -72,7 +75,7 @@
'LOCATION': "db-redis:6379",
'OPTIONS': {
'DB': 1,
'PASSWORD': REDIS_PASSWORD,
'PASSWORD': REDIS_PASSWORD, # noqa F405
},
'TIMEOUT': 300
}
Expand Down Expand Up @@ -125,13 +128,13 @@
},
}

if 'default' in SECRET_KEY:
if 'default' in SECRET_KEY: # noqa F405
print("WARNING: SECRET_KEY is defaulted. Makes sure to override SECRET_KEY in local_untracked or env var")

if 'SENTRY_RAVEN_DSN' in os.environ:
import raven
RAVEN_CONFIG = {
'dsn': SENTRY_RAVEN_DSN,
'dsn': SENTRY_RAVEN_DSN, # noqa F405
# If you are using git, you can also automatically configure the
# release based on the git info.
'release': raven.fetch_git_sha(os.path.abspath(os.curdir)),
Expand Down
21 changes: 11 additions & 10 deletions config/settings/docker_dev.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
"""
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved.
:author nicholas.long@nrel.gov
File contains settings needed to run SEED with docker
"""
from __future__ import absolute_import

# use importlib module to find the local_untracked file rather than a hard-coded path
import importlib
import os
import sys

from config.settings.common import * # noqa

from celery.utils import LOG_LEVELS
from config.settings.common import * # noqa
from kombu import Exchange, Queue

# override MEDIA_URL (requires nginx which dev stack doesn't use)
MEDIA_URL = '/media/'
Expand Down Expand Up @@ -44,16 +47,16 @@
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': POSTGRES_DB,
'USER': POSTGRES_USER,
'PASSWORD': POSTGRES_PASSWORD,
'NAME': POSTGRES_DB, # noqa F405
'USER': POSTGRES_USER, # noqa F405
'PASSWORD': POSTGRES_PASSWORD, # noqa F405
'HOST': "db-postgres",
'PORT': POSTGRES_PORT,
'PORT': POSTGRES_PORT, # noqa F405
}
}

if SEED_TESTING:
INSTALLED_APPS += (
INSTALLED_APPS += ( # noqa F405
"django_nose",
)
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
Expand Down Expand Up @@ -126,8 +129,6 @@
},
}

# use importlib module to find the local_untracked file rather than a hard-coded path
import importlib

local_untracked_spec = importlib.util.find_spec('config.settings.local_untracked')
if local_untracked_spec is None:
Expand Down
2 changes: 1 addition & 1 deletion config/settings/local_untracked.py.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved.
:author
:license: see LICENSE for more details.

Expand Down
19 changes: 11 additions & 8 deletions config/settings/test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
"""
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved.
:author
"""
from __future__ import absolute_import

from config.settings.common import * # noqa
# use importlib module to find the local_untracked file rather than a hard-coded path
import importlib
import logging
import os

from celery.utils import LOG_LEVELS
from config.settings.common import * # noqa

PASSWORD_HASHERS = (
'django.contrib.auth.hashers.MD5PasswordHasher',
Expand Down Expand Up @@ -34,7 +39,7 @@
CELERY_LOG_LEVEL = LOG_LEVELS['WARNING']

# Testing
INSTALLED_APPS += (
INSTALLED_APPS += ( # noqa F405
"django_nose",
)
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
Expand Down Expand Up @@ -75,8 +80,6 @@
},
}

# use importlib module to find the local_untracked file rather than a hard-coded path
import importlib

local_untracked_spec = importlib.util.find_spec('config.settings.local_untracked')
if local_untracked_spec is None:
Expand All @@ -85,6 +88,6 @@
from config.settings.local_untracked import * # noqa


# suppress some logging -- only show warnings or greater
# logging.getLogger('faker.factory').setLevel(logging.ERROR)
# logging.disable(logging.WARNING)
# suppress some logging on faker -- only show warnings or greater
logging.getLogger('faker.factory').setLevel(logging.ERROR)
logging.disable(logging.WARNING)
3 changes: 2 additions & 1 deletion config/settings/test_local_untracked.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved. # NOQA
:copyright (c) 2014 - 2022, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Department of Energy) and contributors. All rights reserved.
:author
:license: see LICENSE for more details.
Expand All @@ -15,6 +15,7 @@
For local dev, all these services can run locally on localhost, 127.0.0.1, or 0.0.0.0.
"""
import os

from kombu import Exchange, Queue

DEBUG = True
Expand Down

0 comments on commit 3b8e88b

Please sign in to comment.