Skip to content

Commit c0323ac

Browse files
refactor: replace python-dateutil with stdlib timezone
- Replace dateutil.tz.tzoffset() with timezone(timedelta(seconds=offset)) from stdlib - Remove python-dateutil==2.9.0.post0 dependency entirely - Remove types-python-dateutil==2.9.0.20250516 type stubs - Update XMP sidecar generation to use standard library datetime timezone handling - Reduce external dependencies by using built-in Python functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b93c144 commit c0323ac

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

REFACTORING_CONTEXT.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,31 @@ This refactoring series implements dependency injection patterns and functional
8585

8686
**Pattern**: Dead code elimination - Remove unused services
8787

88+
### 8. Enable Code Quality Standards for pyicloud_ipd
89+
**Commit**: `6de74ac - refactor: enable formatting, linting, and typechecking for pyicloud_ipd`
90+
91+
**Changes**:
92+
- Removed pyicloud_ipd from ruff exclusions in pyproject.toml
93+
- Fixed 91 linting issues across 14 files (import organization, modern Python syntax, exception handling)
94+
- Fixed 8 mypy strict typing errors (type annotations, constructor calls)
95+
- Applied consistent formatting using ruff format
96+
- Updated to modern Python patterns (f-strings, `X | Y` unions, specific exception handling)
97+
98+
**Pattern**: Code quality standardization
99+
100+
### 9. Remove Unused Dependencies
101+
**Commits**: `62cdaae - refactor: remove unused six dependency` and `[current] - refactor: replace python-dateutil with stdlib timezone`
102+
103+
**Changes**:
104+
- Removed explicit `six==1.17.0` dependency (only needed transitively by python-dateutil and srp)
105+
- Removed `types-six==1.17.0.20250515` type stubs
106+
- Replaced `dateutil.tz.tzoffset()` with `timezone(timedelta(seconds=offset))` from stdlib
107+
- Removed `python-dateutil==2.9.0.post0` dependency entirely
108+
- Removed `types-python-dateutil==2.9.0.20250516` type stubs
109+
- Updated XMP sidecar generation to use standard library datetime timezone handling
110+
111+
**Pattern**: Dependency minimization - Use standard library when possible
112+
88113
## Key Patterns Implemented
89114

90115
### 1. **Dependency Injection**
@@ -137,6 +162,7 @@ After: PhotoLibrary receives params, session, service_endpoint directly
137162
- **Code Quality**: ruff linting passes with no issues
138163
- **Formatting**: ruff format applied consistently
139164
- **Code Reduction**: 694+ lines of unused code removed from pyicloud_ipd services
165+
- **Dependency Optimization**: Removed unused dependencies (six, python-dateutil)
140166

141167
## File Changes Summary
142168

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ dependencies = [
2727
"schema==0.7.7",
2828
"tqdm==4.67.1",
2929
"piexif==1.1.3",
30-
"python-dateutil==2.9.0.post0",
3130
"urllib3==1.26.20",
3231
"typing_extensions==4.14.0",
3332
"Flask==3.1.1",
@@ -69,7 +68,6 @@ test = [
6968
"pytest-timeout==2.4.0",
7069
"pytest-xdist==3.7.0",
7170
"mypy==1.16.0",
72-
"types-python-dateutil==2.9.0.20250516",
7371
"types-pytz==2025.2.0.20250516",
7472
"types-tzlocal==5.1.0.1",
7573
"types-requests==2.31.0.2",

src/icloudpd/xmp_sidecar.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
import os
99
import plistlib
1010
import zlib
11-
from datetime import datetime
11+
from datetime import datetime, timedelta, timezone
1212
from typing import Any, NamedTuple
1313
from xml.etree import ElementTree
1414

15-
import dateutil.tz
16-
1715
from foundation import version_info
1816

1917
exif_tool = None
@@ -150,7 +148,7 @@ def build_metadata(asset_record: dict[str, Any]) -> XMPMetadata:
150148
timezone_offset = asset_record["fields"]["timeZoneOffset"]["value"]
151149
create_date = datetime.fromtimestamp(
152150
int(asset_record["fields"]["assetDate"]["value"]) / 1000,
153-
tz=dateutil.tz.tzoffset(None, timezone_offset),
151+
tz=timezone(timedelta(seconds=timezone_offset)),
154152
)
155153

156154
rating = None

0 commit comments

Comments
 (0)