mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-06-22 21:03:55 +02:00
Optional: Add auto-walrus (#158)
To learn the use of the Walrus opperator this hook integrates it in your code if it finds a reason for it. This branch is a suggestion of mine to force the use of the walrus operaor as an autofix to keep it in mind when programming. This should not increase the workload for us. It just lets us confront a new programming tool. It also isn't a rull to be follwed. Just a hook that looks at your code with an autofix.
This commit is contained in:
@ -87,3 +87,8 @@ repos:
|
|||||||
rev: 0.26.3
|
rev: 0.26.3
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-github-workflows
|
- id: check-github-workflows
|
||||||
|
|
||||||
|
- repo: https://github.com/MarcoGorelli/auto-walrus
|
||||||
|
rev: v0.2.2
|
||||||
|
hooks:
|
||||||
|
- id: auto-walrus
|
||||||
|
@ -113,8 +113,7 @@ def get_district_court_id(name: str, city: str | None, db: Session) -> int:
|
|||||||
The id / privat key of a district court in the SQL-database.
|
The id / privat key of a district court in the SQL-database.
|
||||||
"""
|
"""
|
||||||
name, city = _refine_district_court_entry(name, city)
|
name, city = _refine_district_court_entry(name, city)
|
||||||
court_id = _read_district_court_id(name, city, db)
|
if (court_id := _read_district_court_id(name, city, db)) is not None:
|
||||||
if court_id is not None:
|
|
||||||
return court_id
|
return court_id
|
||||||
court = entities.DistrictCourt(name=name, city=city)
|
court = entities.DistrictCourt(name=name, city=city)
|
||||||
db.add(court)
|
db.add(court)
|
||||||
@ -147,8 +146,7 @@ def get_person_id(
|
|||||||
f'At least one of the three values name: "{name}", surname: "{surname}" or date_of_birth: "{date_of_birth}" is empty.'
|
f'At least one of the three values name: "{name}", surname: "{surname}" or date_of_birth: "{date_of_birth}" is empty.'
|
||||||
)
|
)
|
||||||
assert isinstance(date_of_birth, date) # noqa: S101
|
assert isinstance(date_of_birth, date) # noqa: S101
|
||||||
person_id = _read_person_id(name, surname, date_of_birth, db)
|
if (person_id := _read_person_id(name, surname, date_of_birth, db)) is not None:
|
||||||
if person_id is not None:
|
|
||||||
return person_id
|
return person_id
|
||||||
person = entities.Person(name=name, surname=surname, date_of_birth=date_of_birth)
|
person = entities.Person(name=name, surname=surname, date_of_birth=date_of_birth)
|
||||||
db.add(person)
|
db.add(person)
|
||||||
@ -404,6 +402,7 @@ def add_annual_financial_reports(companies: list[dict], db: Session) -> None:
|
|||||||
for year, report in yearly_results.items():
|
for year, report in yearly_results.items():
|
||||||
if not report:
|
if not report:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
year_int = int(year)
|
year_int = int(year)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
Reference in New Issue
Block a user