Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.10.0 #170

Merged
merged 12 commits into from
Mar 4, 2025
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
26 changes: 5 additions & 21 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,44 +29,28 @@ feature, which is why we encourage you to follow the procedure depicted above as
Our code formatting rules are implicitly defined by using multiple tools. You can check your code against these
standards by running:

```commandline
make lint
```

This is a meta-rule that runs all the utilities used for checking and applying Flama coding standards, but it can be
done individually as follows:

### Code formatting

Flama uses Black for formatting the code to adhere to the Black code style ([PEP 8](https://peps.python.org/pep-0008/)
compliant):
Flama uses Ruff for formatting the code ([PEP 8](https://peps.python.org/pep-0008/) compliant):

```commandline
make black
```

### Imports ordering

Isort is used to reorganize library imports:

```commandline
make isort
make format
```

### Code quality checking

Ruff is used to determine if the code quality is high enough as required to be accepted:

```commandline
make ruff
make lint
```

### Static type checking

Flama is completely static typed. To make sure your code fulfils this constraint, you can check it using mypy:
Flama is completely static typed. To make sure your code fulfils this constraint, you can check it using pyright:

```commandline
make mypy
make typecheck
```

This will automatically fix any style violations in your code.
Expand Down
45 changes: 22 additions & 23 deletions .github/workflows/test_and_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ on:
branches:
- master
paths-ignore:
- 'examples/**'
- '.github/**'
- 'docs/**'
- 'scripts/**'
- 'Dockerfiles/**'
- "examples/**"
- ".github/**"
- "docs/**"
- "scripts/**"
- "Dockerfiles/**"

env:
DEFAULT_LINUX: "slim"
Expand All @@ -22,9 +22,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
container:
image: python:${{ matrix.python }}
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@master
with:
Expand All @@ -34,24 +32,25 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 22
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python }}
enable-cache: true
cache-dependency-glob: "uv.lock"
- id: install
name: Install requirements
run: |
pip install pip poetry --upgrade
./scripts/install
- id: black
name: Install project
run: ./scripts/install
- id: format
name: Code format checking
run: ./scripts/black --check .
- id: isort
name: Imports order checking
run: ./scripts/isort --check .
- id: ruff
name: Code style (ruff)
run: ./scripts/ruff .
- id: pyright
run: ./scripts/format --check .
- id: lint
name: Code linting
run: ./scripts/lint --output-format=github .
- id: typecheck
name: Static types check
run: ./scripts/pyright
run: ./scripts/typecheck
- id: tests
name: Tests
run: ./scripts/test
Expand Down
33 changes: 16 additions & 17 deletions .github/workflows/test_pull_request_branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ jobs:
strategy:
matrix:
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
container:
image: python:${{ matrix.python }}
steps:
- uses: actions/checkout@master
with:
Expand All @@ -22,24 +20,25 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 22
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python }}
enable-cache: true
cache-dependency-glob: "uv.lock"
- id: install
name: Install requirements
run: |
pip install pip poetry --upgrade
./scripts/install
- id: black
name: Install project
run: ./scripts/install
- id: format
name: Code format checking
run: ./scripts/black --check .
- id: isort
name: Imports order checking
run: ./scripts/isort --check .
- id: ruff
name: Code style (ruff)
run: ./scripts/ruff .
- id: pyright
run: ./scripts/format --check .
- id: lint
name: Code linting
run: ./scripts/lint --output-format=github .
- id: typecheck
name: Static types check
run: ./scripts/pyright
run: ./scripts/typecheck
- id: tests
name: Tests
run: ./scripts/test
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dist/
downloads/
eggs/
.eggs/
lib/
./lib/
lib64/
parts/
sdist/
Expand Down Expand Up @@ -61,4 +61,5 @@ demo.db
test.db

# Templates
flama/templates
flama/templates
templates/out
56 changes: 23 additions & 33 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,56 +1,46 @@
fail_fast: true
repos:
- repo: [email protected]:pre-commit/pre-commit-hooks
- repo: [email protected]:pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: check-added-large-files
- id: check-added-large-files
args:
- --maxkb=2000
- id: check-merge-conflict
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: name-tests-test
- --maxkb=2000
- id: check-merge-conflict
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: name-tests-test
args:
- --django
- --django
exclude: "asserts.py|utils.py"
- id: pretty-format-json
- id: pretty-format-json
args:
- --autofix
- --indent=2
- --autofix
- --indent=2
exclude: "templates/.+\\.json"
- repo: [email protected]:alessandrojcm/commitlint-pre-commit-hook
- repo: [email protected]:alessandrojcm/commitlint-pre-commit-hook
rev: v8.0.0
hooks:
- id: commitlint
stages: [commit-msg]
- repo: local
- repo: local
hooks:
- id: black
name: Black - Code Style
entry: ./scripts/black
args:
- -q
- --safe
- --line-length=120
language: system
types: [file, python]
exclude: "make"
- id: isort
name: Isort - Sort Imports
entry: ./scripts/isort
- id: format
name: Code formatting
entry: ./scripts/format
language: system
types: [file, python]
exclude: "make"
- id: ruff
name: Ruff - Code Linter
entry: ./scripts/ruff --fix
- id: lint
name: Code linting
entry: ./scripts/lint --fix
language: system
types: [file, python]
exclude: "make"
- id: pyright
name: Pyright - Static types check
entry: ./scripts/pyright
- id: types
name: Static types check
entry: ./scripts/typecheck
language: system
types: [file, python]
exclude: "(make|tests/|examples/)"
24 changes: 9 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ install: ## Installs the package, JS requirements, and build templates needed
build: ## Builds the package, and templates needed
@./scripts/build

lint: ## Runs a linting pipeline: black, isort, ruff, and mypy
@./scripts/lint

lint-fix: ## Runs a linting pipeline with auto fixing: black, isort, ruff, and mypy
@./scripts/lint --fix

test: ## Runs all tests of the repository
@./scripts/test

Expand All @@ -27,22 +21,22 @@ publish: ## Publishes the package in PiPy if user and passwords are correct
version: ## Gets the current version of the package
@./scripts/version

isort: ## Runs isort on Flama
@./scripts/isort .
format: ## Runs code formatting
@./scripts/format .

black: ## Runs black on Flama
@./scripts/black .
lint: ## Runs code linting
@./scripts/lint .

ruff: ## Runs ruff on Flama
@./scripts/ruff .
lint-fix: ## Runs code linting with autofixing
@./scripts/lint --fix .

pyright: ## Runs pyright on Flama
@./scripts/pyright
typecheck: ## Runs static types checking
@./scripts/typecheck

docker_push: ## Push docker images to registry
@./scripts/docker_push .

.PHONY: help check clean install build lint tests publish version isort black ruff pyright docker_push
.PHONY: help check clean install build tests publish version format lint lint-fix typecheck docker_push
.DEFAULT_GOAL := help

help:
Expand Down
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ and production-ready services, offering automatic deployment for ML models.

Some remarkable characteristics:

* Generic classes for API resources with the convenience of standard CRUD methods over SQLAlchemy tables.
* A schema system (based on Marshmallow or Typesystem) which allows the declaration of inputs and outputs of endpoints
- Generic classes for API resources with the convenience of standard CRUD methods over SQLAlchemy tables.
- A schema system (based on Marshmallow or Typesystem) which allows the declaration of inputs and outputs of endpoints
very easily, with the convenience of reliable and automatic data-type validation.
* Dependency injection to make ease the process of managing parameters needed in endpoints via the use of `Component`s.
- Dependency injection to make ease the process of managing parameters needed in endpoints via the use of `Component`s.
Flama ASGI objects like `Request`, `Response`, `Session` and so on are defined as `Component`s ready to be injected in
your endpoints.
* `Component`s as the base of the plugin ecosystem, allowing you to create custom or use those already defined in your
- `Component`s as the base of the plugin ecosystem, allowing you to create custom or use those already defined in your
endpoints, injected as parameters.
* Auto generated API schema using OpenAPI standard.
* Auto generated `docs`, and provides a Swagger UI and ReDoc endpoints.
* Automatic handling of pagination, with several methods at your disposal such as `limit-offset` and `page numbering`,
- Auto generated API schema using OpenAPI standard.
- Auto generated `docs`, and provides a Swagger UI and ReDoc endpoints.
- Automatic handling of pagination, with several methods at your disposal such as `limit-offset` and `page numbering`,
to name a few.

## Installation
Expand All @@ -52,7 +52,7 @@ Flama is fully compatible with all [supported versions](https://devguide.python.
you to use the latest version available.

For a detailed explanation on how to install flama
visit: [https://flama.dev/docs/getting-started/installation](https://flama.dev/docs/getting-started/installation).
visit: [https://flama.dev/docs/getting-started/installation](https://flama.dev/docs/getting-started/installation).

## Getting Started

Expand All @@ -68,11 +68,7 @@ Visit [https://flama.dev/docs/](https://flama.dev/docs/) to view the full docume
```python
from flama import Flama

app = Flama(
title="Hello-🔥",
version="1.0",
description="My first API",
)
app = Flama()


@app.route("/")
Expand Down Expand Up @@ -101,8 +97,8 @@ flama run examples.hello_flama:app

## Authors

* José Antonio Perdiguero López ([@perdy](https://github.com/perdy/))
* Miguel Durán-Olivencia ([@migduroli](https://github.com/migduroli/))
- José Antonio Perdiguero López ([@perdy](https://github.com/perdy/))
- Miguel Durán-Olivencia ([@migduroli](https://github.com/migduroli/))

## Contributing

Expand Down
Loading