Skip to content

Commit

Permalink
Optimise pyprojectomls (#258)
Browse files Browse the repository at this point in the history
* chore: optimised the pyproject.toml for mock-site

* chore: optimised the pyproject.toml for consent-api
  • Loading branch information
guifry authored Jan 15, 2025
1 parent 8cfb7a5 commit 31d11b9
Show file tree
Hide file tree
Showing 7 changed files with 1,039 additions and 5,642 deletions.
2,526 changes: 163 additions & 2,363 deletions apps/consent-api/poetry.lock

Large diffs are not rendered by default.

72 changes: 10 additions & 62 deletions apps/consent-api/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,81 +1,29 @@
[tool.poetry]
name = "consent-api"
version = "0.1.0"
description = "Single Consent is a service that streamlines user cookie preferences across multiple websites by generating a unique ID for each user's consent choice, centrally storing it, and ensuring subsequent websites respect those preferences."
description = "Consent API extracted from monolith"
authors = ["Your Name <you@example.com>"]
license = "MIT License - Copyright (c) 2023 Government Digital Service - See ./LICENSE"
license = "MIT License"
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
aiosqlite = "0.19.0"
alembic = "1.12.0"
asyncpg = "0.28.0"
alembic = "1.12.0"
essentials = "1.1.5"
fastapi-etag = "0.4.0"
gunicorn = "21.2.0"
httpx = "0.25.0"
locust = "^2.17.0"
pytest = "7.4.2"
pytest-asyncio = "0.21.1"
pytest-cov = "4.1.0"
pytest-splinter4 = "0.3.0"
pytest-xdist = "3.3.1"
python-dotenv = "1.0.0"
selenium = "4.9.1"
wtforms = "3.1.0"
uvicorn = {version = "^0.23.2", extras = ["standard"]}
starlette = "^0.41.3"
pydantic = "^2.10.3"
fastapi = { version = "^0.115.6", extras = ["standard"] }
uvicorn = { version = "^0.23.2", extras = ["standard"] }
pydantic = "^2.10.3"
pydantic-settings = "^2.0.3"
sqlmodel = "^0.0.22"
python-multipart = "^0.0.19"
fastapi = {extras = ["standard"], version = "^0.115.6"}
govuk-frontend-jinja = "^3.4.0"
pretty-errors = "^1.2.25"
requests = "^2.32.3"


[tool.poetry.group.infra.dependencies]
pulumi = ">=3.0.0,<4.0.0"
pulumi-gcp = ">=6.0.0,<7.0.0"
ruamel-yaml = "0.17.21"
google-cloud-run = "^0.10.0"

gunicorn = "^23.0.0"

[tool.poetry.group.dev.dependencies]
ipython = "8.10.0"
pre-commit = "^3.5.0"


[tool.poetry.group.ci.dependencies]
aiosqlite = "0.19.0"
black = "22.12.0"
flake8 = "6.0.0"
flake8-bugbear = "22.10.27"
flake8-docstrings = "1.6.0"
isort = "5.11.4"
mypy = "0.991"
pep8-naming = "0.13.2"
types-sqlalchemy = "1.4.53.17"
pytest = "7.4.2"
pytest-cov = "4.1.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"


[tool.black]
extend-exclude = "^/migrations/"

[tool.ruff]
extend-exclude = ["migrations"]
extend-ignore = ["E203"]
ignore-init-module-imports = true
select = ["E", "F", "I", "B", "C4", "SIM", "N", "FLY", "UP"]

[tool.ruff.flake8-bugbear]
extend-immutable-calls = ["fastapi.Depends", "fastapi.Form"]

[tool.ruff.isort]
force-single-line = true


3,750 changes: 587 additions & 3,163 deletions apps/mock-site/poetry.lock

Large diffs are not rendered by default.

60 changes: 9 additions & 51 deletions apps/mock-site/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,69 +1,27 @@
[tool.poetry]
name = "consent-api"
name = "mock-site"
version = "0.1.0"
description = "Single Consent is a service that streamlines user cookie preferences across multiple websites by generating a unique ID for each user's consent choice, centrally storing it, and ensuring subsequent websites respect those preferences."
description = "A mock frontend app that can interface with the Single Consent API, for E2E testing and smoke tests."
authors = ["Your Name <you@example.com>"]
license = "MIT License - Copyright (c) 2023 Government Digital Service - See ./LICENSE"

[tool.poetry.dependencies]
python = "^3.11"
aiosqlite = "0.19.0"
alembic = "1.12.0"
asyncpg = "0.28.0"
essentials = "1.1.5"
fastapi-etag = "0.4.0"
gunicorn = "21.2.0"
httpx = "0.25.0"
locust = "^2.17.0"
pytest = "7.4.2"
pytest-asyncio = "0.21.1"
pytest-cov = "4.1.0"
pytest-splinter4 = "0.3.0"
pytest-xdist = "3.3.1"
python-dotenv = "1.0.0"
selenium = "4.9.1"
wtforms = "3.1.0"
uvicorn = {version = "^0.23.2", extras = ["standard"]}
starlette = "^0.41.3"
pydantic = "^2.10.3"
sqlmodel = "^0.0.22"
python-multipart = "^0.0.19"
fastapi = {extras = ["standard"], version = "^0.115.6"}
govuk-frontend-jinja = "^3.4.0"
jinja2 = "^3.1.2"
python-dotenv = "1.0.0"
pretty-errors = "^1.2.25"


[tool.poetry.group.infra.dependencies]
pulumi = ">=3.0.0,<4.0.0"
pulumi-gcp = ">=6.0.0,<7.0.0"
ruamel-yaml = "0.17.21"
google-cloud-run = "^0.10.0"


[tool.poetry.group.dev.dependencies]
ipython = "8.10.0"
pre-commit = "^3.5.0"


[tool.poetry.group.ci.dependencies]
aiosqlite = "0.19.0"
black = "22.12.0"
flake8 = "6.0.0"
flake8-bugbear = "22.10.27"
flake8-docstrings = "1.6.0"
isort = "5.11.4"
mypy = "0.991"
pep8-naming = "0.13.2"
types-sqlalchemy = "1.4.53.17"
starlette = "^0.41.3"
pydantic = "^2.10.3"
uvicorn = {version = "^0.23.2", extras = ["standard"]}
gunicorn = "^23.0.0"
itsdangerous = "^2.2.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"


[tool.black]
extend-exclude = "^/migrations/"

[tool.ruff]
extend-exclude = ["migrations"]
extend-ignore = ["E203"]
Expand Down
73 changes: 73 additions & 0 deletions apps/mock-site/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import os
import sys

def get_tree_structure_and_contents(root_dir, extensions):
structure = []
file_contents = []

# Helper function to recursively build the tree and gather file contents
def build_tree_and_collect_contents(path, prefix=""):
entries = sorted(os.listdir(path))
has_valid_files = False
sub_structure = []

for i, entry in enumerate(entries):
full_path = os.path.join(path, entry)
is_last = (i == len(entries) - 1)

if os.path.isdir(full_path):
# Recursively process subdirectories
result = build_tree_and_collect_contents(full_path, prefix + ("│ " if not is_last else " "))
if result:
sub_structure.append(f"{prefix}{'└── ' if is_last else '├── '}{entry}/")
sub_structure.extend(result)
has_valid_files = True
elif any(entry.endswith(ext) for ext in extensions):
# Add file to the tree structure
sub_structure.append(f"{prefix}{'└── ' if is_last else '├── '}{entry}")
has_valid_files = True

# Collect the content of the file
try:
with open(full_path, 'r', encoding='utf-8') as f:
content = f.read()
file_contents.append(f"===== {entry} =====\n{content}\n")
except Exception as e:
file_contents.append(f"===== {entry} =====\nError reading file: {e}\n")

return sub_structure if has_valid_files else None

# Start building the tree and collecting contents from the root directory
root_tree = build_tree_and_collect_contents(root_dir)
if root_tree:
structure.append(f"{root_dir}/")
structure.extend(root_tree)

return structure, file_contents

def main():
if len(sys.argv) < 2:
print("Usage: python script.py <extension1> <extension2> ...")
sys.exit(1)

# Collect the file extensions to filter by
extensions = [f".{ext.lstrip('.')}" for ext in sys.argv[1:]]

# Get tree structure and file contents for the current directory
root_dir = os.getcwd()
structure, file_contents = get_tree_structure_and_contents(root_dir, extensions)

# Write to output file
with open("structure.txt", "w", encoding='utf-8') as file:
if structure:
file.write("\n".join(structure) + "\n\n")
else:
file.write("No files found with specified extensions.\n\n")

# Append file contents
file.write("\n".join(file_contents))

print("Directory structure and file contents written to structure.txt")

if __name__ == "__main__":
main()
Loading

0 comments on commit 31d11b9

Please sign in to comment.