Skip to content

Commit e72c6ad

Browse files
refactor: improve exception handling and update dependencies
- Use BaseException instead of Exception for comprehensive error handling - Change all enum values to uppercase - Update dependencies to latest versions
1 parent 396e4d4 commit e72c6ad

File tree

9 files changed

+267
-223
lines changed

9 files changed

+267
-223
lines changed

archipy/adapters/starrocks/sqlalchemy/session_managers.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,7 @@ def _get_connect_args(self) -> dict:
208208
"""Return connection arguments for async StarRocks to ensure proper transaction support.
209209
210210
StarRocks (using MySQL protocol) requires autocommit to be explicitly disabled
211-
to ensure transactions work properly with rollback support.
212-
213-
Returns:
211+
to ensure transactions work properly with rollback support. Returns:
214212
A dictionary with autocommit=False to ensure transaction support.
215213
"""
216214
return {"autocommit": False}

archipy/helpers/decorators/sqlalchemy_atomic.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@
5454
R = TypeVar("R")
5555

5656

57-
def _handle_db_exception(exception: Exception, db_type: str, func_name: str) -> None:
57+
def _handle_db_exception(exception: BaseException, db_type: str, func_name: str) -> None:
5858
"""Handle database exceptions and raise appropriate errors.
5959
6060
Args:
61-
exception (Exception): The exception to handle.
61+
exception (BaseException): The exception to handle.
6262
db_type (str): The database type ("postgres", "sqlite", or "starrocks").
6363
func_name (str): The name of the function being executed.
6464
@@ -243,7 +243,7 @@ async def async_wrapper(*args: Any, **kwargs: Any) -> R:
243243
async with session.begin():
244244
result = await func(*args, **kwargs)
245245
return result
246-
except Exception as exception:
246+
except BaseException as exception:
247247
await session.rollback()
248248
func_name = getattr(func, "__name__", "unknown")
249249
_handle_db_exception(exception, db_type, func_name)
@@ -291,7 +291,7 @@ def sync_wrapper(*args: Any, **kwargs: Any) -> R:
291291
else:
292292
with session.begin():
293293
return func(*args, **kwargs)
294-
except Exception as exception:
294+
except BaseException as exception:
295295
session.rollback()
296296
func_name = getattr(func, "__name__", "unknown")
297297
_handle_db_exception(exception, db_type, func_name)

archipy/models/types/base_types.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ class FilterOperationType(Enum):
4848
IS_NOT_NULL (str): Represents a check if a value is not null.
4949
"""
5050

51-
EQUAL = "equal"
52-
NOT_EQUAL = "not_equal"
53-
LESS_THAN = "less_than"
54-
LESS_THAN_OR_EQUAL = "less_than_or_equal"
55-
GREATER_THAN = "greater_than"
56-
GREATER_THAN_OR_EQUAL = "greater_than_or_equal"
57-
IN_LIST = "in_list"
58-
NOT_IN_LIST = "not_in_list"
59-
LIKE = "like"
60-
ILIKE = "ilike"
61-
STARTS_WITH = "starts_with"
62-
ENDS_WITH = "ends_with"
63-
CONTAINS = "contains"
64-
IS_NULL = "is_null"
65-
IS_NOT_NULL = "is_not_null"
51+
EQUAL = "EQUAL"
52+
NOT_EQUAL = "NOT_EQUAL"
53+
LESS_THAN = "LESS_THAN"
54+
LESS_THAN_OR_EQUAL = "LESS_THAN_OR_EQUAL"
55+
GREATER_THAN = "GREATER_THAN"
56+
GREATER_THAN_OR_EQUAL = "GREATER_THAN_OR_EQUAL"
57+
IN_LIST = "IN_LIST"
58+
NOT_IN_LIST = "NOT_IN_LIST"
59+
LIKE = "LIKE"
60+
ILIKE = "ILIKE"
61+
STARTS_WITH = "STARTS_WITH"
62+
ENDS_WITH = "ENDS_WITH"
63+
CONTAINS = "CONTAINS"
64+
IS_NULL = "IS_NULL"
65+
IS_NOT_NULL = "IS_NOT_NULL"

archipy/models/types/email_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ class EmailAttachmentDispositionType(StrEnum):
3131
INLINE (str): Represents an attachment that should be displayed inline.
3232
"""
3333

34-
ATTACHMENT = "attachment"
35-
INLINE = "inline"
34+
ATTACHMENT = "ATTACHMENT"
35+
INLINE = "INLINE"

archipy/models/types/sort_order_type.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ class SortOrderType(Enum):
1212
DESCENDING (str): Represents sorting in descending order.
1313
"""
1414

15-
ASCENDING = "ascending"
16-
DESCENDING = "descending"
15+
ASCENDING = "ASCENDING"
16+
DESCENDING = "DESCENDING"

archipy/models/types/time_interval_unit_type.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ class TimeIntervalUnitType(str, Enum):
1010
seamless integration with string-based APIs or databases.
1111
"""
1212

13-
SECONDS = "seconds"
14-
MINUTES = "minutes"
15-
HOURS = "hours"
16-
DAYS = "days"
17-
WEEKS = "weeks"
18-
MONTHS = "months"
19-
YEAR = "year"
13+
SECONDS = "SECONDS"
14+
MINUTES = "MINUTES"
15+
HOURS = "HOURS"
16+
DAYS = "DAYS"
17+
WEEKS = "WEEKS"
18+
MONTHS = "MONTHS"
19+
YEAR = "YEAR"

docs/changelog.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,55 @@
22

33
All notable changes to ArchiPy are documented in this changelog, organized by version.
44

5+
## [v4.0.4] - 2026-01-31
6+
7+
### Changed
8+
9+
#### Helpers - Decorators
10+
11+
- **Enhanced Exception Handling** - Improved exception handling in SQLAlchemy atomic decorators
12+
- Changed exception handling from `Exception` to `BaseException` for comprehensive error catching
13+
- Updated `_handle_db_exception()` function signature to accept `BaseException` instead of `Exception`
14+
- Enhanced error handling in both sync and async atomic decorator implementations
15+
- Ensures all exceptions (including system exceptions) are properly caught and handled
16+
17+
#### Models - Types
18+
19+
- **Enum Value Standardization** - Standardized all enum values to uppercase format for consistency
20+
- **SortOrderType**: Changed `ASCENDING` and `DESCENDING` from lowercase to uppercase
21+
- **FilterOperationType**: Changed all 15 operation types to uppercase (EQUAL, NOT_EQUAL, LESS_THAN, LESS_THAN_OR_EQUAL, GREATER_THAN, GREATER_THAN_OR_EQUAL, IN_LIST, NOT_IN_LIST, LIKE, ILIKE, STARTS_WITH, ENDS_WITH, CONTAINS, IS_NULL, IS_NOT_NULL)
22+
- **EmailAttachmentDispositionType**: Changed `ATTACHMENT` and `INLINE` from lowercase to uppercase
23+
- **TimeIntervalUnitType**: Changed all 7 unit types to uppercase (SECONDS, MINUTES, HOURS, DAYS, WEEKS, MONTHS, YEAR)
24+
- Improved consistency with other enum patterns in the codebase
25+
- Enhanced code readability and standardization across all type definitions
26+
27+
### Fixed
28+
29+
#### Adapters - StarRocks
30+
31+
- **Docstring Formatting** - Fixed docstring formatting in StarRocks session manager
32+
- Corrected docstring formatting in `get_connection_args()` method
33+
- Improved code documentation consistency
34+
35+
### Chore
36+
37+
#### Dependencies
38+
39+
- **Comprehensive Dependency Updates** - Updated multiple dependencies to latest versions
40+
- Updated `cachetools` from `>=6.2.4` to `>=6.2.6` (cache, keycloak, minio, scylladb extras)
41+
- Updated `cryptography` from `46.0.3` to `46.0.4` for enhanced security
42+
- Updated `protobuf` from `>=6.33.4` to `>=6.33.5` (grpc extra)
43+
- Updated `pyjwt` from `>=2.10.1` to `>=2.11.0` (jwt extra)
44+
- Updated `python-keycloak` from `>=7.0.2` to `>=7.0.3` (keycloak extra)
45+
- Updated `python-multipart` from `0.0.21` to `0.0.22`
46+
- Updated `rich` from `14.3.0` to `14.3.1`
47+
- Updated `rich-toolkit` from `0.17.1` to `0.17.2`
48+
- Updated `sentry-sdk` from `>=2.50.0` to `>=2.51.0` (sentry extra)
49+
- Updated `ty` from `>=0.0.13` to `>=0.0.14` (dev dependency)
50+
- Updated `mkdocstrings` from `>=1.0.1` to `>=1.0.2` (docs dependency)
51+
- Updated `pathspec` from `1.0.3` to `1.0.4`
52+
- Updated `orjson` from `3.11.5` to `3.11.6`
53+
554
## [v4.0.3] - 2026-01-24
655

756
### Added

pyproject.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,26 @@ license = { file = "LICENSE" }
2020
# Core optional dependencies
2121
aiosqlite = ["aiosqlite>=0.22.1"]
2222
behave = ["behave>=1.3.3"]
23-
cache = ["cachetools>=6.2.4", "async-lru>=2.1.0"]
23+
cache = ["cachetools>=6.2.6", "async-lru>=2.1.0"]
2424
dependency-injection = ["dependency-injector>=4.48.3"]
2525
elastic-apm = ["elastic-apm>=6.25.0"]
2626
elasticsearch = ["elasticsearch>=9.2.1"]
2727
elasticsearch-async = ["elasticsearch[async]>=9.2.1"]
2828
fakeredis = ["fakeredis>=2.33.0"]
2929
fastapi = ["fastapi[all]>=0.128.0"]
30-
grpc = ["grpcio>=1.76.0", "grpcio-health-checking>=1.76.0", "protobuf>=6.33.4"]
31-
jwt = ["pyjwt>=2.10.1"]
30+
grpc = ["grpcio>=1.76.0", "grpcio-health-checking>=1.76.0", "protobuf>=6.33.5"]
31+
jwt = ["pyjwt>=2.11.0"]
3232
kafka = ["confluent-kafka>=2.13.0"]
3333
kavenegar = ["kavenegar>=1.1.2"]
34-
keycloak = ["python-keycloak>=7.0.2", "cachetools>=6.2.4", "async-lru>=2.1.0"]
35-
minio = ["minio>=7.2.20", "cachetools>=6.2.4", "async-lru>=2.1.0"]
34+
keycloak = ["python-keycloak>=7.0.3", "cachetools>=6.2.6", "async-lru>=2.1.0"]
35+
minio = ["minio>=7.2.20", "cachetools>=6.2.6", "async-lru>=2.1.0"]
3636
parsian-ipg = ["zeep>=4.3.2", "requests[socks]>=2.32.5"]
3737
postgres = ["psycopg[binary,pool]>=3.3.2"]
3838
prometheus = ["prometheus-client>=0.24.1"]
3939
redis = ["redis[hiredis]>=7.1.0"]
4040
scheduler = ["apscheduler>=3.11.2"]
41-
scylladb = ["scylla-driver>=3.29.7", "lz4>=4.4.5", "cachetools>=6.2.4", "async-lru>=2.1.0"]
42-
sentry = ["sentry-sdk>=2.50.0"]
41+
scylladb = ["scylla-driver>=3.29.7", "lz4>=4.4.5", "cachetools>=6.2.6", "async-lru>=2.1.0"]
42+
sentry = ["sentry-sdk>=2.51.0"]
4343
sqlalchemy = ["sqlalchemy>=2.0.46"]
4444
sqlalchemy-async = ["sqlalchemy[asyncio]>=2.0.46"]
4545
starrocks = ["starrocks>=1.3.3", "pymysql>=1.1.2"]
@@ -68,7 +68,7 @@ dev = [
6868
"add-trailing-comma>=4.0.0",
6969
"bandit>=1.9.3",
7070
"codespell>=2.4.1",
71-
"ty>=0.0.13",
71+
"ty>=0.0.14",
7272
"pre-commit-hooks>=6.0.0",
7373
"pre-commit>=4.5.1",
7474
"ruff>=0.14.14",
@@ -86,7 +86,7 @@ docs = [
8686
"mkdocs-material>=9.7.1",
8787
"mkdocs>=1.6.1",
8888
"mkdocstrings-python>=2.0.1",
89-
"mkdocstrings>=1.0.1",
89+
"mkdocstrings>=1.0.2",
9090
"pymdown-extensions>=10.20.1",
9191
]
9292

0 commit comments

Comments
 (0)