From 1183c1a72b2050eea0b5291665a8a51bcee6a467 Mon Sep 17 00:00:00 2001 From: Muzzammil Shahid Date: Thu, 1 Aug 2024 19:48:23 +0500 Subject: [PATCH] Replace requirements file with pyproject.toml --- Makefile | 2 +- crud/main.py | 16 ++------ pyproject.toml | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ requirements.txt | 6 --- 4 files changed, 100 insertions(+), 19 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements.txt diff --git a/Makefile b/Makefile index 70c0171..8b70d9d 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ install_uv: setup: make install_uv uv venv - uv pip install -r requirements.txt + uv pip install .[test] lint: ./.venv/bin/ruff format . diff --git a/crud/main.py b/crud/main.py index dbd3aab..0702ef0 100644 --- a/crud/main.py +++ b/crud/main.py @@ -69,9 +69,7 @@ def activate(invocation: Invocation) -> Result: raise Exception(err) otp_query = select(Otp.otp).where(Otp.email == validated_data["email"]) - account_query = select(TempAccount).where( - TempAccount.email == validated_data["email"] - ) + account_query = select(TempAccount).where(TempAccount.email == validated_data["email"]) with session() as sess: otp_result = sess.execute(otp_query) @@ -121,14 +119,10 @@ def update(invocation: Invocation) -> Result: input_data = {} if invocation.args is None or len(invocation.args) != 1: - raise ApplicationError( - "io.xconn.invalid_argument", ["Exactly 1 arguments are required: email"] - ) + raise ApplicationError("io.xconn.invalid_argument", ["Exactly 1 arguments are required: email"]) if invocation.kwargs is None: - raise ApplicationError( - "io.xconn.invalid_argument", ["provide fields to update as kwargs"] - ) + raise ApplicationError("io.xconn.invalid_argument", ["provide fields to update as kwargs"]) email = invocation.args[0] @@ -161,9 +155,7 @@ def update(invocation: Invocation) -> Result: @app.register("io.xconn.account.delete") def delete(invocation: Invocation) -> Result: if invocation.args is None or len(invocation.args) != 1: - raise ApplicationError( - "io.xconn.invalid_argument", ["Exactly 1 arguments are required: email"] - ) + raise ApplicationError("io.xconn.invalid_argument", ["Exactly 1 arguments are required: email"]) email = invocation.args[0] account_query = select(Account).where(Account.email == email) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3ca7d0f --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,95 @@ +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "crud-wamp" +version = "0.1.0" +authors = [ + { name = "Muzzammil Shahid", email = "muzzammil@xconn.io" }, +] +description = "https://github.com/xconn-projects/crud-wamp" +readme = "README.md" +dependencies = [ + "sqlalchemy", + "xconn@git+https://github.com/xconnio/xconn-python", + "marshmallow", + "marshmallow-sqlalchemy", +] +requires-python = ">=3.10" + +[project.optional-dependencies] +test = [ + "ruff", +] + +[tool.ruff] +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".ipynb_checkpoints", + ".mypy_cache", + ".nox", + ".pants.d", + ".pyenv", + ".pytest_cache", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".vscode", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "site-packages", + "venv", +] + +line-length = 120 +indent-width = 4 + +target-version = "py312" + +[tool.ruff.lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +select = ["E4", "E7", "E9", "F", "E501"] +ignore = [] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[tool.ruff.format] +quote-style = "double" + +indent-style = "space" + +skip-magic-trailing-comma = false + +line-ending = "auto" + +# Enable auto-formatting of code examples in docstrings. Markdown, +# reStructuredText code/literal blocks and doctests are all supported. +# +# This is currently disabled by default, but it is planned for this +# to be opt-out in the future. +docstring-code-format = false + +# Set the line length limit used when formatting code snippets in +# docstrings. +# +# This only has an effect when the `docstring-code-format` setting is +# enabled. +docstring-code-line-length = "dynamic" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index fe317d1..0000000 --- a/requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -sqlalchemy~=2.0.31 -marshmallow~=3.21.3 -marshmallow-sqlalchemy -ruff - -git+https://github.com/xconnio/xconn-python.git@main#egg=xconn