Skip to content

Commit

Permalink
feat: cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
cofin authored Oct 20, 2024
2 parents 03e33d6 + d358f1b commit a2c89e7
Show file tree
Hide file tree
Showing 191 changed files with 5,941 additions and 7,478 deletions.
2 changes: 1 addition & 1 deletion .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ SAQ_CONCURRENCY=1
VITE_HOST=localhost
VITE_PORT=5174
VITE_HOT_RELOAD=True
VITE_DEV_MODE=False
VITE_DEV_MODE=True
54 changes: 0 additions & 54 deletions .eslintrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: ["3.11","3.12"]
python-version: ["3.11", "3.12"]
steps:
- name: Check out repository
uses: actions/checkout@v4
Expand Down
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ dist-ssr
tsconfig.tsbuildinfo

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
Expand All @@ -167,10 +165,10 @@ tmp/
temp/

# built files from the web UI
src/app/domain/web/public
src/app/domain/web/public/hot
app/domain/web/public
app/domain/web/public/hot
.vite
src/app/domain/web/static
app/domain/web/static
public/hot
public/bundle
pdm-pythn
Expand Down
22 changes: 10 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-ast
- id: check-case-conflict
Expand All @@ -11,24 +11,22 @@ repos:
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.5.6
rev: v0.7.0
hooks:
- id: ruff
args:
- --fix
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
- repo: local
hooks:
- id: prettier
- id: local-biome-check
name: biome check
entry: npx biome check --write --files-ignore-unknown=true --no-errors-on-unmatched
language: system
types: [text]
files: "\\.(jsx?|tsx?|c(js|ts)|m(js|ts)|d\\.(ts|cts|mts)|jsonc?|css|svelte|vue|astro|graphql|gql)$"
exclude: templates|migrations|scripts|docs|dist|.venv|public
- repo: https://github.com/ariebovenberg/slotscheck
rev: v0.19.0
hooks:
- id: slotscheck
exclude: test_*|docs|migrations|scripts
entry: env PYTHONPATH=src slotscheck
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.1
rev: v1.12.0
hooks:
- id: mypy
exclude: scripts/
Expand Down
14 changes: 0 additions & 14 deletions .prettierignore

This file was deleted.

7 changes: 0 additions & 7 deletions .prettierrc.json

This file was deleted.

27 changes: 19 additions & 8 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
{
"recommendations": [
"mikestead.dotenv",
"christian-kohler.path-intellisense",
"ms-python.vscode-pylance",
"ms-python.python",
"charliermarsh.ruff",
"ms-python.mypy-type-checker"
]
"recommendations": [
"mikestead.dotenv",
"christian-kohler.path-intellisense",
"ms-python.vscode-pylance",
"ms-python.python",
"charliermarsh.ruff",
"ms-python.mypy-type-checker",
"njpwerner.autodocstring",
"samuelcolvin.jinjahtml",
"formulahendry.code-runner",
"editorconfig.editorconfig",
"irongeek.vscode-env",
"dbaeumer.vscode-eslint",
"xyz.plsql-language",
"davidanson.vscode-markdownlint",
"bradlc.vscode-tailwindcss",
"esbenp.prettier-vscode",
"ms-python.pylint"
]
}
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"pythonArgs": ["-Xfrozen_modules=off"],
"configurations": [
{
"name": "Litestar Run",
"type": "debugpy",
"request": "launch",
"module": "litestar",
"envFile": "${workspaceFolder}/.env",
"args": ["--app-dir", "${workspaceFolder}/", "--app", "app.asgi:create_app", "run", "--port", "8088", "--web-concurrency", "1"],
"justMyCode": false,
"console": "integratedTerminal"
}
]
}
122 changes: 122 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"files.exclude": {
"**/._*": true,
"**/*.pyc": {
"when": "$(basename).py"
},
".coverage.*": true,
".mypy_cache": true,
"**/__pycache__": true,
".venv": true,
".direnv": true,
".idea": true,
".run": true,
".pytest_cache": true,
".cache": true,
".dist": true,
"**/.pytest_cache": true,
"site": true,
".angular": true,
".ruff_cache": true,
".astro": true,
".unasyncd_cache": true,
".coverage": true,
"node_modules": true,
".terraform": true,
".logfire": true
},
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true,
"**/.direnv/**/*": true,
"**/.venv/**/*": true,
"app/domain/web/public/**/*": true
},
"ruff.format.args": ["--config=${workspaceFolder}/pyproject.toml"],
"ruff.lint.run": "onType",
"ruff.lint.args": ["--config=${workspaceFolder}/pyproject.toml"],
"mypy-type-checker.importStrategy": "fromEnvironment",
"black-formatter.importStrategy": "fromEnvironment",
"pylint.importStrategy": "fromEnvironment",
"pylint.args": ["--rcfile=pylintrc"],
"python.autoComplete.extraPaths": ["${workspaceFolder}"],
"python.terminal.activateEnvInCurrentTerminal": true,
"python.terminal.executeInFileDir": true,
"python.testing.pytestEnabled": true,
"autoDocstring.guessTypes": false,
"python.analysis.autoImportCompletions": true,
"python.analysis.autoFormatStrings": true,
"editor.formatOnSave": true,
"notebook.formatOnSave.enabled": true,
"black-formatter.args": ["--line-length=120"],
"evenBetterToml.formatter.reorderKeys": true,
"evenBetterToml.formatter.trailingNewline": true,
"evenBetterToml.formatter.columnWidth": 120,
"evenBetterToml.formatter.arrayAutoCollapse": true,
"python.globalModuleInstallation": false,
"python.testing.unittestEnabled": false,
"python.testing.autoTestDiscoverOnSaveEnabled": true,
"editor.codeActionsOnSave": {
"source.fixAll.ruff": "explicit",
"source.organizeImports.ruff": "explicit"
},
"[python]": {
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"editor.insertSpaces": true,
"editor.tabSize": 4,
"editor.trimAutoWhitespace": true,
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
}
},
"python.analysis.fixAll": ["source.unusedImports", "source.convertImportFormat"],
"sqltools.disableReleaseNotifications": true,
"sqltools.disableNodeDetectNotifications": true,
"python.testing.unittestArgs": ["-v", "-s", "./tests", "-p", "test_*.py"],
"python.testing.pytestArgs": ["tests"],
"explorer.fileNesting.patterns": {
"pyproject.toml": "pyproject.toml,poetry.lock,poetry.toml,mkdocs.yaml,.gcloudignore,.gitignore,.editorconfig,.bumpversion.cfg,.pylintrc,.pre-commit-config.yaml,LICENSE,mkdocs.yml,service_account.json,.pdm-python,pdm.lock,uv.lock,requirements.txt,sonar-project.properties,railway.json",
".env": ".env*,.*.env",
"docker-compose.yml": "docker-compose.yml, .dockerignore, docker-compose.*.yml, docker-compose.*.yaml",
"package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml, bun.lockb, tsconfig.*.json, tsconfig.json, .stylelintrc.json,angular.json,proxy.conf.json,cypress.*.ts,extra-webpack*.cjs,.eslintrc.json, tailwind.config.*, vite.config.ts, postcss.config.*, components.json, .prettierignore, .prettierrc.json, .eslintrc.cjs"
},
"markdownlint.run": "onSave",
"markdownlint.config": {
"default": true,
"MD046": {
"style": "fenced"
},
"MD007": {
"indent": 4
},
"no-hard-tabs": false
},
"yaml.schemas": {
"https://squidfunk.github.io/mkdocs-material/schema.json": "mkdocs.yml"
},
"yaml.customTags": [
"!ENV scalar",
"!ENV sequence",
"!relative scalar",
"tag:yaml.org,2002:python/name:material.extensions.emoji.to_svg",
"tag:yaml.org,2002:python/name:material.extensions.emoji.twemoji",
"tag:yaml.org,2002:python/name:pymdownx.superfences.fence_code_format"
],
"mypy-type-checker.preferDaemon": true,
"mypy-type-checker.reportingScope": "file",
"editor.defaultFormatter": "charliermarsh.ruff",
"notebook.defaultFormatter": "charliermarsh.ruff",
"python.analysis.regenerateStdLibIndices": true,
"python.analysis.typeEvaluation.deprecateTypingAliases": true,
"python.analysis.typeEvaluation.enableExperimentalFeatures": true,
"python.analysis.typeEvaluation.enableReachabilityAnalysis": true,
"python.analysis.typeEvaluation.strictListInference": true,
"python.analysis.typeEvaluation.strictDictionaryInference": true,
"python.analysis.typeEvaluation.strictSetInference": false,
"editor.defaultFoldingRangeProvider": "charliermarsh.ruff",
"python.analysis.enableSyncServer": false
}
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ USING_NPM = $(shell python3 -c "if __import__('pathlib').Path('pac
ENV_PREFIX =.venv/bin/
VENV_EXISTS = $(shell python3 -c "if __import__('pathlib').Path('.venv/bin/activate').exists(): print('yes')")
NODE_MODULES_EXISTS = $(shell python3 -c "if __import__('pathlib').Path('node_modules').exists(): print('yes')")
SRC_DIR =src
BUILD_DIR =dist
PDM_OPTS ?=
PDM ?= pdm $(PDM_OPTS)

Expand Down Expand Up @@ -65,7 +63,7 @@ install: ## Install the project and
if [ "$(VENV_EXISTS)" ]; then $(MAKE) clean; fi
@if [ "$(NODE_MODULES_EXISTS)" ]; then echo "=> Removing existing node modules"; fi
if [ "$(NODE_MODULES_EXISTS)" ]; then $(MAKE) destroy-node_modules; fi
@if [ "$(USING_PDM)" ]; then $(PDM) config venv.in_project true && python3 -m venv --copies .venv && . $(ENV_PREFIX)/activate && $(ENV_PREFIX)/pip install --quiet -U wheel setuptools cython pip mypy nodeenv; fi
@if [ "$(USING_PDM)" ]; then $(PDM) config venv.in_project true; fi
@if [ "$(USING_PDM)" ]; then $(PDM) install -G:all; fi
@echo "=> Install complete! Note: If you want to re-install re-run 'make install'"

Expand Down Expand Up @@ -161,7 +159,7 @@ docs-clean: ## Dump the existing built docs

docs-serve: docs-clean ## Serve the docs locally
@echo "=> Serving documentation"
$(PDM_RUN_BIN) sphinx-autobuild docs docs/_build/ -j auto --watch src --watch docs --watch tests --watch CONTRIBUTING.rst --port 8002
$(PDM_RUN_BIN) sphinx-autobuild docs docs/_build/ -j auto --watch app --watch docs --watch tests --watch CONTRIBUTING.rst --port 8002

docs: docs-clean ## Dump the existing built docs and rebuild them
@echo "=> Building documentation"
Expand Down
3 changes: 2 additions & 1 deletion src/app/__main__.py → app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def run_cli() -> None:

current_path = Path(__file__).parent.parent.resolve()
sys.path.append(str(current_path))
os.environ.setdefault("LITESTAR_APP", "app.asgi:app")
os.environ.setdefault("LITESTAR_APP", "app.asgi:create_app")
os.environ.setdefault("LITESTAR_APP_NAME", "Litestar Fullstack Inertia")
try:
from litestar.__main__ import run_cli as run_litestar_cli

Expand Down
12 changes: 12 additions & 0 deletions app/__metadata__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Metadata for the Project."""

from __future__ import annotations

import importlib.metadata

__all__ = ["__version__", "__project__"]

__version__ = importlib.metadata.version("app")
"""Version of the project."""
__project__ = importlib.metadata.metadata("app")["Name"]
"""Name of the project."""
16 changes: 16 additions & 0 deletions app/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from litestar import Litestar


def create_app() -> Litestar:
"""Create ASGI application."""

from litestar import Litestar

from app.server import plugins

return Litestar(plugins=[plugins.app_core])
Loading

0 comments on commit a2c89e7

Please sign in to comment.