Skip to content

Commit fb48b4c

Browse files
committed
Update dependencies, etc.
1 parent af95ff4 commit fb48b4c

26 files changed

+1798
-1126
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
*.hdf5
33
.idea/
44

5+
env/
6+
venv/
7+
.venv/
8+
env3*/
9+
510
# Byte-compiled / optimized / DLL files
611
__pycache__/
712
*.py[cod]

Makefile

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ tests_src = tests
66
docs_src = docs/src
77
all_src = $(pkg_src) $(tests_src)
88

9-
isort = isort -rc $(all_src)
10-
autoflake = autoflake -r --remove-all-unused-imports --ignore-init-module-imports $(all_src)
11-
black = black $(all_src)
12-
flake8 = flake8 $(all_src)
139
mypy_base = mypy --show-error-codes
1410
mypy = $(mypy_base) $(all_src)
1511
test = pytest --cov=fastapi_utils
@@ -26,13 +22,13 @@ test:
2622

2723
.PHONY: format ## Auto-format the source code (isort, autoflake, black)
2824
format:
29-
$(isort)
30-
$(autoflake) -i
31-
$(black)
25+
black $(all_src)
26+
ruff --fix $(all_src)
3227

33-
.PHONY: lint ## Run flake8 over the application source and tests
28+
.PHONY: lint
3429
lint:
35-
$(flake8)
30+
ruff $(all_src)
31+
black --check --diff $(all_src)
3632

3733
.PHONY: mypy ## Run mypy over the application source and tests
3834
mypy:
@@ -72,6 +68,7 @@ clean:
7268
rm -rf `find . -type d -name .pytest_cache`
7369
rm -rf `find . -type d -name .cache`
7470
rm -rf `find . -type d -name .mypy_cache`
71+
rm -rf `find . -type d -name .ruff_cache`
7572
rm -rf `find . -type d -name htmlcov`
7673
rm -rf `find . -type d -name "*.egg-info"`
7774
rm -rf `find . -type d -name build`

docs/release-notes.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
## Latest changes
22

3+
## 0.3.0
4+
5+
* Move to ruff for linting, etc.
6+
* Update various dependencies
7+
* Stop supporting Python 3.6 (due to inability to run in GitHub actions)
8+
* Deprecate InferringRouter (as its functionality is now built into `fastapi.APIRouter`)
9+
* Resolve various deprecationwarnings introduced by sqlalchemy 1.4.
10+
311
## 0.2.1
412

513
* Fix bug with multiple decorators on same method

docs/src/camelcase2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from sqlalchemy.ext.declarative import declarative_base, declared_attr
1+
from sqlalchemy.orm import declarative_base, declared_attr
22

33
from fastapi_utils.camelcase import camel2snake
44

docs/src/class_based_views1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import sqlalchemy as sa
55
from fastapi import Depends, FastAPI, Header, HTTPException
6-
from sqlalchemy.ext.declarative import declarative_base
6+
from sqlalchemy.orm import declarative_base
77
from sqlalchemy.orm import Session
88
from starlette.status import HTTP_403_FORBIDDEN, HTTP_404_NOT_FOUND
99

@@ -43,7 +43,7 @@ def get_db() -> Session:
4343

4444

4545
def get_owned_item(session: Session, owner: UserID, item_id: ItemID) -> ItemORM:
46-
item: Optional[ItemORM] = session.query(ItemORM).get(item_id)
46+
item: Optional[ItemORM] = session.get(ItemORM, item_id)
4747
if item is not None and item.owner != owner:
4848
raise HTTPException(status_code=HTTP_403_FORBIDDEN)
4949
if item is None:

docs/src/class_based_views2.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
import sqlalchemy as sa
55
from fastapi import Depends, FastAPI, Header, HTTPException
6-
from sqlalchemy.ext.declarative import declarative_base
7-
from sqlalchemy.orm import Session
6+
from sqlalchemy.orm import Session, declarative_base
87
from starlette.status import HTTP_403_FORBIDDEN, HTTP_404_NOT_FOUND
98

109
from fastapi_utils.api_model import APIMessage, APIModel
@@ -45,7 +44,7 @@ def get_db() -> Session:
4544

4645

4746
def get_owned_item(session: Session, owner: UserID, item_id: ItemID) -> ItemORM:
48-
item: Optional[ItemORM] = session.query(ItemORM).get(item_id)
47+
item: Optional[ItemORM] = session.get(ItemORM, item_id)
4948
if item is not None and item.owner != owner:
5049
raise HTTPException(status_code=HTTP_403_FORBIDDEN)
5150
if item is None:

docs/src/guid1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sqlalchemy as sa
2-
from sqlalchemy.ext.declarative import declarative_base
2+
from sqlalchemy.orm import declarative_base
33

44
from fastapi_utils.guid_type import GUID
55

docs/src/session1.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import sqlalchemy as sa
66
from fastapi import Depends, FastAPI
77
from pydantic import BaseSettings
8-
from sqlalchemy.ext.declarative import declarative_base
9-
from sqlalchemy.orm import Session
8+
from sqlalchemy.orm import Session, declarative_base
109

1110
from fastapi_utils.guid_type import GUID, GUID_DEFAULT_SQLITE
1211
from fastapi_utils.session import FastAPISessionMaker
@@ -43,6 +42,6 @@ def _get_fastapi_sessionmaker() -> FastAPISessionMaker:
4342

4443
@app.get("/{user_id}")
4544
def get_user_name(db: Session = Depends(get_db), *, user_id: UUID) -> str:
46-
user = db.query(User).get(user_id)
45+
user = db.get(User, user_id)
4746
username = user.name
4847
return username

docs/user-guide/basics/guid-type.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ you can use `fastapi_utils.guid_type.GUID_SERVER_DEFAULT_POSTGRESQL`:
5454

5555
```python
5656
import sqlalchemy as sa
57-
from sqlalchemy.ext.declarative import declarative_base
57+
from sqlalchemy.orm import declarative_base
5858

5959
from fastapi_utils.guid_type import GUID, GUID_SERVER_DEFAULT_POSTGRESQL
6060

@@ -89,7 +89,7 @@ create new records):
8989

9090
```python
9191
import sqlalchemy as sa
92-
from sqlalchemy.ext.declarative import declarative_base
92+
from sqlalchemy.orm import declarative_base
9393

9494
from fastapi_utils.guid_type import GUID, GUID_DEFAULT_SQLITE
9595

fastapi_utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.2.1"
1+
__version__ = "0.3.0"

0 commit comments

Comments
 (0)