Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .ast-grep/rule-tests/no-framework-imports-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
id: no-framework-imports
valid:
- import json
- from foca.plugins import Context, Plugin
- from foca.plugins.model import InboundRequest
- import flaskless
- from starlettes import x
invalid:
- import flask
- import flask.json
- import werkzeug.exceptions as wz
- import json, connexion
- from flask import request
- from connexion.exceptions import BadRequestProblem
- from starlette.requests import Request
- from werkzeug import exceptions
- from foca.plugins.adapter import current_principal
- from foca.plugins import adapter
- import foca.plugins.adapter
7 changes: 7 additions & 0 deletions .ast-grep/rule-tests/pydantic-v1-dict-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
id: pydantic-v1-dict
valid:
- config.model_dump(exclude_none=True)
- dict(a=1)
invalid:
- config.dict()
- config.dict(exclude_none=True)
33 changes: 33 additions & 0 deletions .ast-grep/rules/no-framework-imports.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
id: no-framework-imports
language: python
severity: error
message: Plugins must not import a web framework
note: |
Plugins get plain data and an explicit context (`foca.plugins`), so that
they run unchanged on every web framework that FOCA supports (Connexion 2
and Flask now, Starlette from FOCA 1.0). Don't import Flask, Werkzeug,
Connexion or Starlette, nor FOCA's framework glue `foca.plugins.adapter`;
use what the hooks get (`InboundRequest`, `Context`, ...) instead.
files:
- plugins/*/*/*/src/**/*.py
rule:
any:
# `import x`, `import x.y as z`, `import a, x`
- kind: import_statement
has:
kind: dotted_name
regex: ^(flask|werkzeug|connexion|starlette|foca\.plugins\.adapter)(\.|$)
stopBy: end
- kind: import_from_statement
has:
field: module_name
regex: ^(flask|werkzeug|connexion|starlette|foca\.plugins\.adapter)(\.|$)
- kind: import_from_statement
all:
- has:
field: module_name
regex: ^foca\.plugins$
- has:
field: name
regex: ^adapter$
stopBy: end
9 changes: 9 additions & 0 deletions .ast-grep/rules/pydantic-v1-dict.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
id: pydantic-v1-dict
language: python
severity: error
message: Pydantic v1 method `.dict()`
note: |
Use `.model_dump()` (Pydantic v2). For other objects with a `.dict()`
method, suppress the finding with `# ast-grep-ignore: pydantic-v1-dict`.
rule:
pattern: $MODEL.dict($$$ARGS)
27 changes: 27 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Editor settings (https://editorconfig.org), consistent with the pre-commit
# hooks (end-of-file-fixer, trailing-whitespace) and ruff
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# Line length as in ruff (`line-length` in `pyproject.toml`)
[*.{py,pyi}]
indent_style = space
indent_size = 4
max_line_length = 88

[*.toml]
indent_style = space
indent_size = 4

[*.{yaml,yml,json}]
indent_style = space
indent_size = 2

# Two trailing spaces are a hard line break in Markdown; prefer a backslash
[*.md]
trim_trailing_whitespace = false
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Code owners are requested for review on pull requests that change matching
# files. To add owners for a path, add a line below the catch-all (the last
# matching pattern wins): the path, then the owners' GitHub logins, each
# prefixed with `@`, e.g. `/docs/` followed by `@uniqueg`. See
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
* @uniqueg
43 changes: 43 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: 2
# Every entry targets `dev` (`target-branch`), which takes all pull
# requests whatever the default branch is (`main` only moves forward to
# releases); security updates always target the default branch, though
updates:
# `uv.lock` and the `pyproject.toml` files of the workspace (the root and
# every package)
- package-ecosystem: uv
directory: /
schedule:
interval: monthly
target-branch: dev
versioning-strategy: increase-if-necessary
ignore:
# FOCA comes from its `dev` branch until 0.18.0 is released (see
# `tool.uv.sources` in `pyproject.toml`); its bounds are raised by hand
- dependency-name: foca
groups:
# Dependencies of the documentation (the `docs` group), in pull
# requests of their own
docs-dependencies:
patterns: ["mkdocs", "mkdocs-*", "pymdown-extensions"]
# Dependencies match the first group listed
python-dependencies:
patterns: ["*"]
# Actions in the workflows
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
target-branch: dev
groups:
github-actions:
patterns: ["*"]
# Hook revisions in `.pre-commit-config.yaml`
- package-ecosystem: pre-commit
directory: /
schedule:
interval: monthly
target-branch: dev
groups:
pre-commit:
patterns: ["*"]
Loading
Loading