Skip to content
Open
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
3 changes: 1 addition & 2 deletions agenda_api/models/pessoa_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ class PessoaRead(PessoaCreate):
def _set_pessoa_id(cls, data):
"""altera o campo _id para pessoa_id
e o a alias para "pessoa_id" """
document_id = data.get("_id")
if document_id:
if document_id := data.get("_id"):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PessoaRead._set_pessoa_id refactored with the following changes:

data["pessoa_id"] = document_id
return data

Expand Down
6 changes: 3 additions & 3 deletions agenda_api/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ class PessoasRepository:
@staticmethod
def get(pessoa_id: str) -> PessoaRead:
"""Get pessoa por seu ID"""
document = collection.find_one({"_id": pessoa_id})
if not document:
if document := collection.find_one({"_id": pessoa_id}):
return PessoaRead(**document)
else:
raise PessoaNotFoundException(pessoa_id)
return PessoaRead(**document)
Comment on lines -17 to -20
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function PessoasRepository.get refactored with the following changes:


@staticmethod
def list() -> PessoasRead:
Expand Down