-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upograde python from 3.9.5 to 3.13.1 #5533
base: master
Are you sure you want to change the base?
Conversation
…NXDRIVE-2929-upgrade-python-from-3.9.5-to-3.12.3
…NXDRIVE-2929-upgrade-python-from-3.9.5-to-3.12.3
…NXDRIVE-2929-upgrade-python-from-3.9.5-to-3.12.3
…st_datetime_adapter_new
…https://github.com/nuxeo/nuxeo-drive into test_datetime_adapter_new
Reviewer's Guide by SourceryThis pull request upgrades the Python version used in the project from 3.9.5 to 3.12.3. Several files were modified to reflect this change, primarily by updating version numbers and resolving compatibility issues related to timezones and database operations. Class diagram showing changes to AutoRetryCursor classclassDiagram
class AutoRetryCursor {
+adapt_datetime_iso(val)
+execute(sql: str, parameters: Iterable[Any])
}
note for AutoRetryCursor "Modified to handle datetime
conversion for SQLite in Python 3.12"
State diagram showing datetime handling changesstateDiagram-v2
[*] --> DatetimeInput
DatetimeInput --> TimezoneAware: datetime.now(tz=timezone.utc)
DatetimeInput --> LegacyHandling: datetime.utcnow()
TimezoneAware --> [*]: New Python 3.12 handling
LegacyHandling --> [*]: Old Python 3.9 handling
note right of TimezoneAware: Updated to use timezone-aware
datetime objects
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
unknown seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @gitofanindya - I've reviewed your changes - here's some feedback:
Overall Comments:
- The SQLite datetime adapter modifications in base.py need careful review and testing to ensure no timezone-related regressions. Consider adding explicit tests for this functionality.
- Remove the 'testing' comment in direct_edit.py
Here's what I looked at during the review
- 🟡 General issues: 4 issues found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
def adapt_datetime_iso(self, val): | ||
return datetime.fromtimestamp(val.strftime('%s'), tz=timezone.utc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Using strftime('%s') is platform-dependent and may not work on Windows
Consider using val.timestamp() instead to get a POSIX timestamp that works across all platforms.
import sqlite3 | ||
# return super().execute(sql, parameters) | ||
# new_param = tuple( datetime.fromtimestamp(param, tz=timezone.utc) if isinstance(param, datetime) else param for param in parameters ) | ||
new_param = tuple( sqlite3.register_adapter(param, self.adapt_datetime_iso) if isinstance(param, datetime) else param for param in parameters ) | ||
|
||
return super().execute(sql, new_param) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (performance): The tuple comprehension creates unnecessary intermediate objects for non-datetime parameters
Consider only transforming datetime objects and keeping other parameters as-is to avoid unnecessary tuple creation.
import sqlite3 | |
# return super().execute(sql, parameters) | |
# new_param = tuple( datetime.fromtimestamp(param, tz=timezone.utc) if isinstance(param, datetime) else param for param in parameters ) | |
new_param = tuple( sqlite3.register_adapter(param, self.adapt_datetime_iso) if isinstance(param, datetime) else param for param in parameters ) | |
return super().execute(sql, new_param) | |
import sqlite3 | |
# Only create a new tuple if we have datetime objects to transform | |
if any(isinstance(param, datetime) for param in parameters): | |
new_params = list(parameters) | |
for i, param in enumerate(parameters): | |
if isinstance(param, datetime): | |
new_params[i] = sqlite3.register_adapter(param, self.adapt_datetime_iso) | |
parameters = tuple(new_params) | |
return super().execute(sql, parameters) |
@@ -1315,7 +1315,7 @@ def get_current_locale() -> str: | |||
l10n_code = NSLocale.currentLocale() | |||
l10n = NSLocale.localeIdentifier(l10n_code) | |||
else: | |||
l10n = locale.getdefaultlocale()[0] or "" | |||
l10n = locale.getlocale()[1] or "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Incorrect index used for locale tuple and potential None handling issue
getlocale() returns (language code, encoding). Using index [1] returns only the encoding. Consider using [0] for language code and handle None case explicitly.
pefile==2023.2.7 ; sys_platform == "win32" \ | ||
--hash=sha256:da185cd2af68c08a6cd4481f7325ed600a88f6a813bad9dea07ab3ef73d8d8d6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Please explain the reason for changing the pefile version.
A brief comment about compatibility or bug fixes would be helpful for future maintainers.
Suggested implementation:
# TODO: Document why pefile 2023.2.7 is required (compatibility/bug fixes?)
pefile==2023.2.7 ; sys_platform == "win32" \
The developer should replace the TODO comment with the actual reason for requiring pefile 2023.2.7, such as:
- If it's due to a compatibility issue with other dependencies
- If there are known bugs in newer versions
- If it's required for specific Windows platform support
2eb4162
to
0509e6d
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5533 +/- ##
==========================================
- Coverage 52.09% 49.26% -2.84%
==========================================
Files 96 96
Lines 16094 16130 +36
==========================================
- Hits 8384 7946 -438
- Misses 7710 8184 +474
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
c6ffe48
to
6958530
Compare
dff2071
to
796d25e
Compare
9f0ee91
to
9f5e9d8
Compare
9f5e9d8
to
9b33ff8
Compare
Summary by Sourcery
Upgrade Python from 3.9.5 to 3.12.3.
Enhancements:
Build:
CI:
Documentation:
Tests: