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
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: pomponchik

---

## Short description

Replace this text with a short description of the error and the behavior that you expected to see instead.


## Describe the bug in detail

Please add this test in such a way that it reproduces the bug you found and does not pass:

```python
def test_your_bug():
...
```

Writing the test, please keep compatibility with the [`pytest`](https://docs.pytest.org/) framework.

If for some reason you cannot describe the error in the test format, describe here the steps to reproduce it.


## Environment
- OS: ...
- Python version (the output of the `python --version` command): ...
- Version of this package: ...
26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Documentation fix
about: Add something to the documentation, delete it, or change it
title: ''
labels: documentation
assignees: pomponchik
---

## It's cool that you're here!

Documentation is an important part of the project, we strive to make it high-quality and keep it up to date. Please adjust this template by outlining your proposal.


## Type of action

What do you want to do: remove something, add it, or change it?


## Where?

Specify which part of the documentation you want to make a change to? For example, the name of an existing documentation section or the line number in a file `README.md`.


## The essence

Please describe the essence of the proposed change
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: pomponchik

---

## Short description

What do you propose and why do you consider it important?


## Some details

If you can, provide code examples that will show how your proposal will work. Also, if you can, indicate which alternatives to this behavior you have considered. And finally, how do you propose to test the correctness of the implementation of your idea, if at all possible?
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: Question or consultation
about: Ask anything about this project
title: ''
labels: guestion
assignees: pomponchik

---

## Your question

Here you can freely describe your question about the project. Please, before doing this, read the documentation provided, and ask the question only if the necessary answer is not there. In addition, please keep in mind that this is a free non-commercial project and user support is optional for its author. The response time is not guaranteed in any way.
14 changes: 11 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -31,6 +31,14 @@ jobs:
shell: bash
run: mypy cbfa --strict

- name: Run mypy for tests
shell: bash
run: mypy tests

- name: Run ruff
shell: bash
run: ruff cbfa
run: ruff check cbfa

- name: Run ruff for tests
shell: bash
run: ruff check tests
9 changes: 6 additions & 3 deletions .github/workflows/tests_and_coverage.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: tests
name: Tests

on:
push
Expand All @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v2
Expand All @@ -28,7 +28,7 @@ jobs:
run: pip install -r requirements_dev.txt

- name: Run tests and show coverage on the command line
run: coverage run --source=cbfa --omit="*tests*" -m pytest --cache-clear && coverage report -m
run: coverage run --source=cbfa --omit="*tests*" -m pytest --cache-clear && coverage report -m --fail-under=100

- name: Upload reports to codecov
env:
Expand All @@ -39,3 +39,6 @@ jobs:
find . -iregex "codecov.*"
chmod +x codecov
./codecov -t ${CODECOV_TOKEN}

- name: Run tests and show the branch coverage on the command line
run: coverage run --branch --source=cbfa --omit="*tests*" -m pytest --cache-clear --assert=plain && coverage report -m --fail-under=100
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ venv
.pytest_cache
test.py
.mypy_cache
.coverage
htmlcov
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ build-backend = 'setuptools.build_meta'

[project]
name = 'cbfa'
version = '0.0.6'
version = '0.0.7'
authors = [
{ name='Evgeniy Blinov', email='zheni-b@yandex.ru' },
]
description = 'Class-based views for the FastAPI'
readme = 'README.md'
requires-python = '>=3.7'
requires-python = '>=3.8'
dependencies = [
'fastapi',
]
Expand All @@ -20,12 +20,12 @@ classifiers = [
'Operating System :: POSIX',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: 3.13',
'License :: OSI Approved :: MIT License',
'Intended Audience :: Developers',
'Topic :: Software Development :: Libraries',
Expand Down
13 changes: 7 additions & 6 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
pytest==7.4.2
coverage==7.2.7
twine==4.0.2
pytest==7.4.3
coverage==7.6.1
twine==6.1.0
wheel==0.40.0
build==0.9.0
ruff==0.0.290
mypy==1.4.1
build==1.2.2.post1
ruff==0.9.9
mypy==1.14.1
mutmut==3.2.3
36 changes: 36 additions & 0 deletions tests/units/test_class_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ def patch(self, url):
return lambda x: x


class PseudoAppWithoutHTTPMethods:
def __init__(self):
self.calls = []


def test_wrap_only_get():
app = PseudoApp()
wrapper = ClassBased(app)
Expand Down Expand Up @@ -73,3 +78,34 @@ def patch():
pass

assert app.calls == [('get', url), ('post', url), ('put', url), ('delete', url), ('trace', url), ('head', url), ('options', url), ('connect', url), ('patch', url)]


def test_wrap_something_which_is_not_supported_in_app():
url = '/kek'
app = PseudoAppWithoutHTTPMethods()
wrapper = ClassBased(app)

@wrapper(url)
class SomeItem:
def get():
pass
def post():
pass
def put():
pass
def delete():
pass
def trace():
pass
def head():
pass
def options():
pass
def connect():
pass
def patch():
pass
def kek():
pass

assert app.calls == []