Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #190 from communitiesuk/FS-2713-use-single-config-…
Browse files Browse the repository at this point in the history
…file

FS-2713 single config file for all code formatters
  • Loading branch information
RamuniN authored Feb 7, 2024
2 parents a2928e5 + 241389f commit e032ded
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 152 deletions.
5 changes: 2 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ repos:
args:
- --experimental-string-processing
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.0.0
hooks:
- id: flake8
args:
- --max-line-length=120
additional_dependencies: [Flake8-pyproject]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
Expand Down
4 changes: 1 addition & 3 deletions config/envs/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,5 @@ class DefaultConfig(object):
FSD_LOG_LEVEL = logging.WARNING

# Database
SQLALCHEMY_DATABASE_URI = environ.get("DATABASE_URL", "").replace(
"postgres://", "postgresql://"
)
SQLALCHEMY_DATABASE_URI = environ.get("DATABASE_URL", "").replace("postgres://", "postgresql://")
SQLALCHEMY_TRACK_MODIFICATIONS = False
4 changes: 1 addition & 3 deletions config/envs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@
class TestConfig(Config):
SECRET_KEY = environ.get("SECRET_KEY", "test")

SQLALCHEMY_DATABASE_URI = environ.get("DATABASE_URL").replace(
"postgres://", "postgresql://"
)
SQLALCHEMY_DATABASE_URI = environ.get("DATABASE_URL").replace("postgres://", "postgresql://")
14 changes: 3 additions & 11 deletions core/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ def get_bulk_accounts(
result = db.session.scalars(stmnt)
account_schema = AccountSchema()

accounts_metadatas = {
str(account_row.id): account_schema.dump(account_row)
for account_row in result
}
accounts_metadatas = {str(account_row.id): account_schema.dump(account_row) for account_row in result}

return accounts_metadatas, 200
except sqlalchemy.exc.NoResultFound:
Expand Down Expand Up @@ -144,10 +141,7 @@ def put_account(account_id: str) -> Tuple[dict, int]:
db.session.flush()
db.session.rollback()
return {
"error": (
f"Email '{email}' cannot be updated - "
"another account may already be using this email"
)
"error": f"Email '{email}' cannot be updated - another account may already be using this email"
}, 401
if full_name:
account.full_name = full_name
Expand Down Expand Up @@ -196,9 +190,7 @@ def post_account() -> Tuple[dict, int]:
if not email_address:
return {"error": "email_address is required"}, 400
try:
new_account = Account(
email=email_address, azure_ad_subject_id=azure_ad_subject_id
)
new_account = Account(email=email_address, azure_ad_subject_id=azure_ad_subject_id)
db.session.add(new_account)
db.session.commit()
new_account_json = {
Expand Down
12 changes: 3 additions & 9 deletions db/migrations/versions/e355f9c4356b_.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table("account", schema=None) as batch_op:
batch_op.add_column(sa.Column("full_name", sa.String(), nullable=True))
batch_op.add_column(
sa.Column("azure_ad_subject_id", sa.String(), nullable=True)
)
batch_op.add_column(sa.Column("azure_ad_subject_id", sa.String(), nullable=True))
batch_op.create_unique_constraint(
batch_op.f("uq_account_azure_ad_subject_id"),
["azure_ad_subject_id"],
Expand Down Expand Up @@ -54,16 +52,12 @@ def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("role")

sa.Enum("LEAD_ASSESSOR", "ASSESSOR", "COMMENTER", name="roletype").drop(
op.get_bind()
)
sa.Enum("LEAD_ASSESSOR", "ASSESSOR", "COMMENTER", name="roletype").drop(op.get_bind())

with op.batch_alter_table("account", schema=None) as batch_op:
batch_op.drop_constraint(batch_op.f("uq_account_id"), type_="unique")
batch_op.drop_constraint(batch_op.f("uq_account_email"), type_="unique")
batch_op.drop_constraint(
batch_op.f("uq_account_azure_ad_subject_id"), type_="unique"
)
batch_op.drop_constraint(batch_op.f("uq_account_azure_ad_subject_id"), type_="unique")
batch_op.drop_column("azure_ad_subject_id")
batch_op.drop_column("full_name")
# ### end Alembic commands ###
8 changes: 2 additions & 6 deletions db/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ class Account(db.Model):
)
email = db.Column("email", db.String(), nullable=False, unique=True)
full_name = db.Column("full_name", db.String(), nullable=True)
azure_ad_subject_id = db.Column(
"azure_ad_subject_id", db.String(), nullable=True, unique=True
)
roles = db.relationship(
"Role", lazy="select", backref=db.backref("account", lazy="joined")
)
azure_ad_subject_id = db.Column("azure_ad_subject_id", db.String(), nullable=True, unique=True)
roles = db.relationship("Role", lazy="select", backref=db.backref("account", lazy="joined"))

@property
def highest_role_map(self) -> Mapping[str, str]:
Expand Down
13 changes: 13 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "funding-service-design-account-store"
version = "0.1.1"
description = "The funding service design account store for the DLUHC."
authors = ["Version One", "HM Government, Department of Levelling Up, Housing and Communities"]
license = "MIT License"

[tool.black]
line-length = 120

[tool.flake8]
max-line-length = 120
count = true
1 change: 1 addition & 0 deletions requirements-dev.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ pytest-mock
pip-tools>=6.13.0
asserts
colored
Flake8-pyproject
17 changes: 14 additions & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# This file is autogenerated by pip-compile with python 3.10
# To update, run:
# This file is autogenerated by pip-compile with Python 3.10
# by the following command:
#
# pip-compile requirements-dev.in
#
Expand Down Expand Up @@ -102,10 +102,14 @@ deepdiff==6.2.1
# via -r requirements-dev.in
distlib==0.3.6
# via virtualenv
exceptiongroup==1.1.1
exceptiongroup==1.2.0
# via pytest
filelock==3.8.0
# via virtualenv
flake8==7.0.0
# via flake8-pyproject
flake8-pyproject==1.2.3
# via -r requirements-dev.in
flask==2.2.5
# via
# -r requirements.txt
Expand Down Expand Up @@ -229,6 +233,8 @@ marshmallow-enum==1.5.1
# via -r requirements.txt
marshmallow-sqlalchemy==0.28.1
# via -r requirements.txt
mccabe==0.7.0
# via flake8
mypy-extensions==0.4.3
# via black
nodeenv==1.7.0
Expand Down Expand Up @@ -278,6 +284,8 @@ pre-commit==3.1.1
# via -r requirements-dev.in
psycopg2==2.9.9
# via -r requirements.txt
pycodestyle==2.11.1
# via flake8
pycparser==2.21
# via
# -r requirements.txt
Expand All @@ -286,6 +294,8 @@ pyee==6.0.0
# via
# -r requirements.txt
# flipper-client
pyflakes==3.2.0
# via flake8
pygments==2.15.0
# via
# -r requirements.txt
Expand Down Expand Up @@ -436,6 +446,7 @@ tomli==2.0.1
# via
# black
# build
# flake8-pyproject
# pep517
# pip-tools
# pytest
Expand Down
3 changes: 1 addition & 2 deletions scripts/migration-task-script.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
# Remove final line break and append arguments
try:
subprocess.run(
args=command_with_image_removed[:-1]
+ f" \\\n--follow \\\n--command '{command_to_run}'",
args=command_with_image_removed[:-1] + f" \\\n--follow \\\n--command '{command_to_run}'",
shell=True,
check=True,
)
Expand Down
Loading

0 comments on commit e032ded

Please sign in to comment.