Skip to content

Commit

Permalink
Merge ab589da into b187590
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed May 16, 2024
2 parents b187590 + ab589da commit cdbeaf5
Show file tree
Hide file tree
Showing 64 changed files with 1,976 additions and 1,332 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
psql -h localhost -U postgres coaster_test -c "grant all privileges on schema public to $(whoami); grant all privileges on all tables in schema public to $(whoami); grant all privileges on all sequences in schema public to $(whoami);"
- name: Test with pytest
run: |
pytest --ignore-flaky --showlocals --cov=coaster
pytest --showlocals --cov=coaster
- name: Prepare coverage report
run: |
mkdir -p coverage
Expand Down
39 changes: 4 additions & 35 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
ci:
skip: ['yesqa', 'no-commit-to-branch']
skip: ['no-commit-to-branch']
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
Expand All @@ -13,35 +13,7 @@ repos:
hooks:
- id: ruff
args: ['--fix', '--exit-non-zero-on-fix']
# Extra args, only after removing flake8 and yesqa: '--extend-select', 'RUF100'
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa
additional_dependencies: &flake8deps
- flake8-assertive
# - flake8-annotations
- flake8-blind-except
- flake8-builtins
- flake8-comprehensions
# - flake8-docstrings
- flake8-isort
- flake8-logging-format
- flake8-mutable
- flake8-print
- pep8-naming
- toml
- tomli
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
additional_dependencies:
- tomli
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
Expand All @@ -56,6 +28,7 @@ repos:
]
additional_dependencies:
- flask
- quart
- lxml-stubs
- sqlalchemy
- toml
Expand All @@ -66,11 +39,6 @@ repos:
- types-requests
- types-toml
- typing-extensions
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: *flake8deps
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
Expand All @@ -88,6 +56,7 @@ repos:
]
additional_dependencies:
- flask
- quart
- sqlalchemy
- tomli
- repo: https://github.com/PyCQA/bandit
Expand Down
21 changes: 9 additions & 12 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
flake8
flake8-assertive
flake8-blind-except
flake8-builtins
flake8-coding
flake8-comprehensions
flake8-isort
flake8-logging-format
flake8-mutable
flake8-print>=5.0.0
isort
pep8-naming
mypy
pre-commit
pylint
ruff
toml
types-bleach
types-Markdown
types-pytz
types-PyYAML
types-requests
types-toml
typing-extensions
2 changes: 2 additions & 0 deletions docs/compat.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.. automodule:: coaster.compat
:members:
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Coaster is available under the BSD license, the same license as Flask.
views/index
sqlalchemy/index
db
nlp
compat

Indices and tables
==================
Expand Down
2 changes: 0 additions & 2 deletions docs/nlp.rst

This file was deleted.

176 changes: 104 additions & 72 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ classifiers = [
]
dependencies = [
'aniso8601',
'asgiref',
'base58>=2.0.0',
'bleach',
'blinker',
Expand All @@ -45,7 +46,6 @@ dependencies = [
'isoweek',
'Markdown>=3.2.0',
'markupsafe',
'nltk>=3.4.5',
'pymdown-extensions>=8.0',
'pytz',
'semantic-version>=2.8.0',
Expand Down Expand Up @@ -103,11 +103,18 @@ sections = ['FUTURE', 'STDLIB', 'THIRDPARTY', 'FIRSTPARTY', 'LOCALFOLDER']

[tool.pytest.ini_options]
pythonpath = 'src'
required_plugins = ['pytest-env', 'pytest-rerunfailures', 'pytest-socket']
required_plugins = [
'pytest-asyncio',
'pytest-env',
'pytest-rerunfailures',
'pytest-socket',
]
asyncio_mode = 'auto'
minversion = '6.0'
addopts = '--doctest-modules --ignore setup.py --cov-report=term-missing'
addopts = '--doctest-modules --ignore setup.py --cov-report=term-missing --strict-markers'
doctest_optionflags = ['ALLOW_UNICODE', 'ALLOW_BYTES']
env = ['FLASK_ENV=testing']
markers = ["has_server_name: App fixture has a server name in config"]

[tool.pylint.master]
max-parents = 10
Expand Down Expand Up @@ -138,20 +145,21 @@ disable = [
'too-many-lines',
'too-many-locals',
'too-many-public-methods',
'unused-argument',
'unsupported-membership-test',
'unused-argument',
# These need some serious refactoring, so disabled for now
'too-many-branches',
'too-many-nested-blocks',
'too-many-statements',
# Let Black, isort and ruff handle these
# Let Ruff handle these
'consider-using-f-string',
'line-too-long',
'wrong-import-position',
'wrong-import-order',
# Let flake8 handle these
'missing-class-docstring',
'missing-function-docstring',
'missing-module-docstring',
'superfluous-parens',
'wrong-import-order',
'wrong-import-position',
]

[tool.mypy]
Expand All @@ -176,63 +184,6 @@ exclude_dirs = ['node_modules', 'build/lib']
skips = ['*/*_test.py', '*/test_*.py']

[tool.ruff]
# This is a slight customisation of the default rules
# 1. Rule E402 (module-level import not top-level) is disabled as isort handles it
# 2. Rule E501 (line too long) is left to Black; some strings are worse for wrapping

# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
lint.select = ["E", "F"]
lint.ignore = ["E402", "E501"]

# Allow autofix for all enabled rules (when `--fix`) is provided.
lint.fixable = [
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"I",
"N",
"Q",
"S",
"T",
"W",
"ANN",
"ARG",
"BLE",
"COM",
"DJ",
"DTZ",
"EM",
"ERA",
"EXE",
"FBT",
"ICN",
"INP",
"ISC",
"NPY",
"PD",
"PGH",
"PIE",
"PL",
"PT",
"PTH",
"PYI",
"RET",
"RSE",
"RUF",
"SIM",
"SLF",
"TCH",
"TID",
"TRY",
"UP",
"YTT",
]
lint.unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
Expand Down Expand Up @@ -260,31 +211,112 @@ exclude = [
# Same as Black.
line-length = 88

# Allow unused variables when underscore-prefixed.
lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# Target Python 3.9
target-version = "py39"

[tool.ruff.lint.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10
[tool.ruff.format]
docstring-code-format = true
quote-style = "preserve"

[tool.ruff.lint]
select = [
"A", # flake8-builtins
"ANN", # flake8-annotations
"ARG", # flake8-unused-arguments
"ASYNC", # flake8-async
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C", # pylint convention
"D", # pydocstyle
"C4", # flake8-comprehensions
"E", # Error
"EM", # flake8-errmsg
"EXE", # flake8-executable
"F", # pyflakes
"FA", # flake8-future-annotations
"G", # flake8-logging-format
"I", # isort
"INP", # flake8-no-pep420
"INT", # flake8-gettext
"ISC", # flake8-implicit-str-concat
"N", # pep8-naming
"PIE", # flake8-pie
"PT", # flake8-pytest-style
"PYI", # flake8-pyi
"RET", # flake8-return
"RUF", # Ruff
"S", # flake8-bandit
"SIM", # flake8-simplify
"SLOT", # flake8-slots
"T20", # flake8-print
"TRIO", # flake8-trio
"UP", # pyupgrade
"W", # Warnings
"YTT", # flake8-2020
]
ignore = [
"ANN002", # `*args` is implicit `Any`
"ANN003", # `**kwargs` is implicit `Any`
"ANN101", # `self` type is implicit
"ANN102", # `cls` type is implicit
"ANN401", # Allow `Any` type
"C901", # TODO: Remove after code refactoring
"D101",
"D102",
"D103",
"D105", # Magic methods don't need docstrings
"D106", # Nested classes don't need docstrings
"D107", # `__init__` doesn't need a docstring
"D203", # No blank lines before class docstring
"D212", # Allow multiline docstring to start on next line after quotes
"D213", # But also allow multiline docstring to start right after quotes
"E402", # Allow top-level imports after statements
"E501", # Allow long lines if the formatter can't fix it
"EM101", # Allow Exception("string")
"EM102", # Allow Exception(f"string")
"ISC001", # Allow implicitly concatenated string literals (required for formatter)
"RUF012", # Allow mutable ClassVar without annotation (conflicts with SQLAlchemy)
"SLOT000", # Don't require `__slots__` for subclasses of str
]

# Allow autofix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow these characters in strings
allowed-confusables = ["", "", ""]

[tool.ruff.lint.extend-per-file-ignores]
"__init__.py" = ["E402"] # Allow non-top-level imports
"tests/**.py" = [
"S101", # Allow assert
"ANN001", # Args don't need types (usually fixtures)
"N802", # Fixture returning a class may be named per class name convention
"N803", # Args don't require naming convention (fixture could be a class)
]

[tool.ruff.lint.isort]
# These config options should match isort config above under [tool.isort]
combine-as-imports = true
extra-standard-library = ['typing_extensions']
split-on-trailing-comma = false
relative-imports-order = 'furthest-to-closest'
known-first-party = ['coaster']
known-first-party = []
section-order = [
'future',
'standard-library',
'third-party',
'first-party',
'repo',
'local-folder',
]

[tool.ruff.lint.isort.sections]
repo = ['coaster']

[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false

[tool.ruff.lint.pyupgrade]
keep-runtime-typing = true
1 change: 1 addition & 0 deletions src/coaster/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# flake8: noqa
"""Coaster provides various support modules for Flask apps."""

from ._version import *
Loading

0 comments on commit cdbeaf5

Please sign in to comment.