Skip to content

Commit 265dd6f

Browse files
committed
Cleaned up
1 parent f0920bc commit 265dd6f

File tree

7 files changed

+21
-25
lines changed

7 files changed

+21
-25
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ jobs:
7070
- name: Build
7171
run: |
7272
export PYTHONUSERBASE=${HOME}/.local
73-
pip install --user wheel
74-
pip install --user -r requirements.txt
75-
${PYTHONUSERBASE}/bin/pylint ${GITHUB_WORKSPACE}/mrmat_python_api_fastapi
73+
pip install --user -r requirements.txt -r requirements.dev.txt
7674
PYTHONPATH=${GITHUB_WORKSPACE} python -m pytest --cov=mrmat_python_api_fastapi
7775
PYTHONPATH=${GITHUB_WORKSPACE} python -m build --wheel -n
7876

.idea/mrmat-python-api-fastapi.iml

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/lint.xml

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mrmat_python_api_fastapi/apis/resource/v1/api.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
summary='List all known resources',
3939
description='Returns all currently known resources and their metadata',
4040
response_model=List[ResourceSchema])
41-
async def get_all(db: Session = Depends(get_db)):
41+
async def get_resources(db: Session = Depends(get_db)):
4242
return db.query(Resource).all()
4343

4444

@@ -47,7 +47,7 @@ async def get_all(db: Session = Depends(get_db)):
4747
summary='Get a single resource',
4848
description='Return a single resource identified by its resource id',
4949
response_model=Union[ResourceSchema, StatusSchema])
50-
async def get(identity: int, db: Session = Depends(get_db)):
50+
async def get_resource(identity: int, db: Session = Depends(get_db)):
5151
resource = db.query(Resource).get(identity).one_or_none()
5252
if not resource:
5353
return JSONResponse(status_code=404,
@@ -60,7 +60,7 @@ async def get(identity: int, db: Session = Depends(get_db)):
6060
summary='Create a resource',
6161
description='Create a resource owned by the authenticated user',
6262
response_model=Union[ResourceSchema, StatusSchema])
63-
async def create(data: ResourceInputSchema, db: Session = Depends(get_db)):
63+
async def create_resource(data: ResourceInputSchema, db: Session = Depends(get_db)):
6464
resource = Resource(name=data.name)
6565
db.add(resource)
6666
db.commit()
@@ -72,7 +72,7 @@ async def create(data: ResourceInputSchema, db: Session = Depends(get_db)):
7272
summary='Modify a resource',
7373
description='Modify a resource by its resource id',
7474
response_model=Union[ResourceSchema, StatusSchema])
75-
async def modify(identity: int, data: ResourceInputSchema, db: Session = Depends(get_db)):
75+
async def modify_resource(identity: int, data: ResourceInputSchema, db: Session = Depends(get_db)):
7676
resource = db.query(Resource).get(identity)
7777
if not resource:
7878
return JSONResponse(status_code=404,
@@ -92,7 +92,7 @@ async def modify(identity: int, data: ResourceInputSchema, db: Session = Depends
9292
status.HTTP_204_NO_CONTENT: {'description': 'The resource was removed'},
9393
status.HTTP_410_GONE: {'description': 'The resource was already gone'}
9494
})
95-
async def remove(identity: int, response: Response, db: Session = Depends(get_db)):
95+
async def remove_resource(identity: int, response: Response, db: Session = Depends(get_db)):
9696
resource = db.query(Resource).get(identity)
9797
if not resource:
9898
return JSONResponse(status_code=204,
@@ -109,7 +109,7 @@ async def remove(identity: int, response: Response, db: Session = Depends(get_db
109109
summary='List all known owners',
110110
description='Returns all currently known owners and their metadata',
111111
response_model=List[OwnerSchema])
112-
async def get_all(db: Session = Depends(get_db)):
112+
async def get_owners(db: Session = Depends(get_db)):
113113
return db.query(Owner).all()
114114

115115

@@ -118,7 +118,7 @@ async def get_all(db: Session = Depends(get_db)):
118118
summary='Get a single owner',
119119
description='Return a single owner identified by its owner id',
120120
response_model=Union[OwnerSchema, StatusSchema])
121-
async def get(identity: int, db: Session = Depends(get_db)):
121+
async def get_owner(identity: int, db: Session = Depends(get_db)):
122122
owner = db.query(Owner).get(identity)
123123
if not owner:
124124
return JSONResponse(status_code=404,
@@ -131,7 +131,7 @@ async def get(identity: int, db: Session = Depends(get_db)):
131131
summary='Create a owner',
132132
description='Create a owner',
133133
response_model=Union[OwnerSchema, StatusSchema])
134-
async def create(data: OwnerInputSchema, db: Session = Depends(get_db)):
134+
async def create_owner(data: OwnerInputSchema, db: Session = Depends(get_db)):
135135
owner = Owner(name=data.name, client_id='TODO')
136136
db.add(owner)
137137
db.commit()
@@ -143,7 +143,7 @@ async def create(data: OwnerInputSchema, db: Session = Depends(get_db)):
143143
summary='Modify a owner',
144144
description='Modify a owner by its owner id',
145145
response_model=Union[OwnerSchema, StatusSchema])
146-
async def modify(identity: int, data: ResourceInputSchema, db: Session = Depends(get_db)):
146+
async def modify_owner(identity: int, data: ResourceInputSchema, db: Session = Depends(get_db)):
147147
owner = db.query(Owner).get(identity)
148148
if not owner:
149149
return JSONResponse(status_code=404,
@@ -163,7 +163,7 @@ async def modify(identity: int, data: ResourceInputSchema, db: Session = Depends
163163
status.HTTP_204_NO_CONTENT: {'description': 'The owner was removed'},
164164
status.HTTP_410_GONE: {'description': 'The owner was already gone'}
165165
})
166-
async def remove(identity: int, response: Response, db: Session = Depends(get_db)):
166+
async def remove_owner(identity: int, response: Response, db: Session = Depends(get_db)):
167167
owner = db.query(Owner).get(identity)
168168
if not owner:
169169
response.status_code = status.HTTP_410_GONE

src/mrmat_python_api_fastapi/apis/resource/v1/db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from sqlalchemy import ForeignKey, Column, Integer, String, UniqueConstraint, BigInteger
2424
from sqlalchemy.orm import relationship
2525

26-
from src.mrmat_python_api_fastapi import Base
26+
from mrmat_python_api_fastapi import Base
2727

2828

2929
class Owner(Base):

src/mrmat_python_api_fastapi/config.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
# SOFTWARE.
2222

23-
from typing import Optional
2423
import os
2524
import json
2625
import secrets
@@ -34,11 +33,11 @@ class Config:
3433
db_url: str = 'sqlite://'
3534

3635
@staticmethod
37-
def from_json_file(file: Optional[os.PathLike] = os.getenv('APP_CONFIG')):
36+
def from_json_file(file: str | None = os.getenv('APP_CONFIG')):
3837
runtime_config = Config()
3938
if file and os.path.exists(file):
4039
with open(file, 'r', encoding='UTF-8') as c:
4140
file_config = json.load(c)
42-
runtime_config.secret_key = file_config.get('secret_key', secrets.token_urlsafe(16))
43-
runtime_config.db_url = file_config.get('db_url', 'sqlite://')
41+
runtime_config.secret_key = file_config.get_owner('secret_key', secrets.token_urlsafe(16))
42+
runtime_config.db_url = file_config.get_owner('db_url', 'sqlite://')
4443
return runtime_config

src/mrmat_python_api_fastapi/db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from sqlalchemy import create_engine
2525
from sqlalchemy.orm import Session, sessionmaker
2626

27-
from src.mrmat_python_api_fastapi import app_config
27+
from mrmat_python_api_fastapi import app_config
2828

2929

3030
@lru_cache

0 commit comments

Comments
 (0)