Skip to content

Commit

Permalink
Merge pull request #98 from KOSASIH/deepsource-transform-6084fe5a
Browse files Browse the repository at this point in the history
style: format code with Autopep8, Black, ClangFormat, dotnet-format, Go fmt, Gofumpt, Google Java Format, isort, Ktlint, PHP CS Fixer, Prettier, RuboCop, Ruff Formatter, Rustfmt, Scalafmt, StandardJS, StandardRB, swift-format and Yapf
  • Loading branch information
KOSASIH authored May 10, 2024
2 parents 263f2e5 + ad34a1c commit c1a4664
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions banking/account_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
from typing import Dict


def create_account(account_type: str, balance: float, customer_id: int) -> Dict:
"""
Create a new account for a customer.
Expand All @@ -18,22 +19,23 @@ def create_account(account_type: str, balance: float, customer_id: int) -> Dict:
# implementation
logging.info(f"Creating account for customer {customer_id}")
# Validate input parameters
if account_type not in ['checking', 'savings']:
if account_type not in ["checking", "savings"]:
raise ValueError("Invalid account type")
if balance < 0:
raise ValueError("Balance cannot be negative")

# Create account and store it in a database or in-memory data structure
account = {
'id': generate_unique_id(),
'type': account_type,
'balance': balance,
'customer_id': customer_id
"id": generate_unique_id(),
"type": account_type,
"balance": balance,
"customer_id": customer_id,
}

# Return the account information
return account


def update_account(account_id: int, account_type: str, balance: float) -> bool:
"""
Update an existing account.
Expand All @@ -49,7 +51,7 @@ def update_account(account_id: int, account_type: str, balance: float) -> bool:
# implementation
logging.info(f"Updating account {account_id}")
# Validate input parameters
if account_type not in ['checking', 'savings']:
if account_type not in ["checking", "savings"]:
raise ValueError("Invalid account type")
if balance < 0:
raise ValueError("Balance cannot be negative")
Expand All @@ -58,15 +60,16 @@ def update_account(account_id: int, account_type: str, balance: float) -> bool:
account = get_account_by_id(account_id)

# Update the account information
account['type'] = account_type
account['balance'] = balance
account["type"] = account_type
account["balance"] = balance

# Save the updated account back to the database or in-memory data structure
save_account(account)

# Return True to indicate success
return True


def delete_account(account_id: int) -> bool:
"""
Delete an account.
Expand Down

0 comments on commit c1a4664

Please sign in to comment.