Skip to content

Commit

Permalink
Merge pull request #49 from azmeuk/py313
Browse files Browse the repository at this point in the history
mega-cleanup
  • Loading branch information
azmeuk authored Oct 13, 2024
2 parents 09b3d47 + a091d5b commit b8a0102
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 100 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ name: tests
on:
push:
branches:
- master
- main
- '*.x'
pull_request:
branches:
- master
- main
- '*.x'
jobs:
tests:
Expand All @@ -21,7 +21,6 @@ jobs:
- '3.11'
- '3.10'
- '3.9'
- '3.8'
- pypy-3.10
steps:
- uses: actions/checkout@v2
Expand Down
29 changes: 6 additions & 23 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,14 @@
---
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: ["--py38-plus"]
- repo: https://github.com/asottile/reorder_python_imports
rev: v3.12.0
hooks:
- id: reorder-python-imports
args: ["--application-directories", "src"]
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.1.11'
rev: v0.6.9
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.5
hooks:
- id: docformatter
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: check-byte-order-marker
- id: check-merge-conflict
- id: debug-statements
- id: fix-byte-order-marker
- id: trailing-whitespace
- id: end-of-file-fixer
12 changes: 12 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Version 0.x.x
-------------

Unreleased

- move the project to pallets-eco organization
- move from `master` branch to `main`
- move to pyproject.toml
- move to src directory
- remove python 3.8 support
- use pre-commit configuration from flask

Version 0.4.1
-------------

Expand Down
1 change: 1 addition & 0 deletions examples/flask/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from flask import render_template
from flask import request
from flask_sqlalchemy import SQLAlchemy

from wtforms_sqlalchemy.orm import model_form

app = Flask(__name__)
Expand Down
80 changes: 80 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,63 @@
[project]
name = "WTForms-SQLAlchemy"
description = "SQLAlchemy tools for WTForms"
readme = "README.rst"
license = {file = "LICENSE.txt"}
maintainers = [{name = "WTForms"}]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Internet :: WWW/HTTP :: WSGI",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
"Topic :: Software Development :: Libraries :: Application Frameworks",
]
requires-python = ">=3.9"
dependencies = [
"WTForms>=3.1",
"SQLAlchemy>=1.4",
]
dynamic = ["version"]

[project.urls]
Documentation = "https://wtforms-sqlalchemy.readthedocs.io/"
Changes = "https://wtforms-sqlalchemy.readthedocs.io/changes/"
"Source Code" = "https://github.com/pallets-eco/wtforms-sqlalchemy/"
"Issue Tracker" = "https://github.com/pallets-eco/wtforms-sqlalchemy/issues/"
Chat = "https://discord.gg/pallets"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["src/wtforms_sqlalchemy"]

[tool.hatch.version]
path = "src/wtforms_sqlalchemy/__init__.py"

[tool.hatch.build]
include = [
"src/",
"docs/",
"tests/",
"CHANGES.rst",
"tox.ini",
]
exclude = [
"docs/_build/",
]

[tool.pytest.ini_options]
testpaths = ["tests"]
filterwarnings = [
"error",
]

[tool.coverage.run]
branch = true
source = ["wtforms_sqlalchemy", "tests"]
Expand All @@ -10,3 +70,23 @@ exclude_lines = [
"pragma: no cover",
"except ImportError:",
]

[tool.ruff]
src = ["src"]
fix = true
show-fixes = true
output-format = "full"

[tool.ruff.lint]
select = [
"B", # flake8-bugbear
"E", # pycodestyle error
"F", # pyflakes
"I", # isort
"UP", # pyupgrade
"W", # pycodestyle warning
]

[tool.ruff.lint.isort]
force-single-line = true
order-by-type = false
61 changes: 0 additions & 61 deletions setup.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions setup.py

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Useful form fields for use with SQLAlchemy ORM."""

import operator
from collections import defaultdict

Expand Down Expand Up @@ -82,7 +83,7 @@ def __init__(
allow_blank=False,
blank_text="",
blank_value="__None",
**kwargs
**kwargs,
):
super().__init__(label, validators, **kwargs)
self.query_factory = query_factory
Expand Down Expand Up @@ -212,7 +213,8 @@ def __init__(self, label=None, validators=None, default=None, **kwargs):
import warnings

warnings.warn(
"allow_blank=True does not do anything for QuerySelectMultipleField."
"allow_blank=True does not do anything for QuerySelectMultipleField.",
stacklevel=2,
)
self._invalid_formdata = False

Expand Down
6 changes: 3 additions & 3 deletions wtforms_sqlalchemy/orm.py → src/wtforms_sqlalchemy/orm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tools for generating forms based on SQLAlchemy models."""

import inspect

from sqlalchemy import inspect as sainspect
Expand Down Expand Up @@ -68,8 +69,7 @@ def get_converter(self, column):
return self.converters[col_type.__name__]

raise ModelConversionError(
"Could not find field converter for column %s (%r)."
% (column.name, types[0])
f"Could not find field converter for column {column.name} ({types[0]!r})."
)

def convert(self, model, mapper, prop, field_args, db_session=None):
Expand Down Expand Up @@ -130,7 +130,7 @@ def convert(self, model, mapper, prop, field_args, db_session=None):
# We have a property with a direction.
if db_session is None:
raise ModelConversionError(
"Cannot convert field %s, need DB session." % prop.key
f"Cannot convert field {prop.key}, need DB session."
)

foreign_model = prop.mapper.class_
Expand Down
4 changes: 2 additions & 2 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def assert_raises_text(e_type, text):
except e_type as e:
if not re.match(text, e.args[0]):
raise AssertionError(
"Exception raised: %r but text %r did not match pattern %r"
% (e, e.args[0], text)
f"Exception raised: {e!r} but text {e.args[0]!r} "
f"did not match pattern {text!r}"
) from e
else:
raise AssertionError(f"Expected Exception {e_type!r}, did not get it")
1 change: 1 addition & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from wtforms.validators import InputRequired
from wtforms.validators import Optional
from wtforms.validators import Regexp

from wtforms_sqlalchemy.fields import QuerySelectField
from wtforms_sqlalchemy.fields import QuerySelectMultipleField
from wtforms_sqlalchemy.orm import model_form
Expand Down
9 changes: 7 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[tox]
envlist = style, py312, py311, py310, py39, py38, coverage, docs
envlist =
py3{12,11,10,9},pypy3{10,9}
style
docs

[testenv]
deps =
pytest
-e .
pytest
commands = pytest {posargs}

[testenv:style]
Expand All @@ -17,6 +21,7 @@ commands = sphinx-build -W -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html

[testenv:coverage]
deps =
-e .
pytest
coverage
commands =
Expand Down

0 comments on commit b8a0102

Please sign in to comment.