Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Rework on #109#111

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
mavwolverine wants to merge6 commits intobobbui:master
base:master
Choose a base branch
Loading
frommavwolverine:upgrade_retry

Conversation

@mavwolverine
Copy link

@mavwolverinemavwolverine commentedJul 12, 2025
edited by qodo-code-reviewbot
Loading

PR Type

Enhancement


Description

  • Modernize Python code to support versions 3.9-3.12

  • Replace deprecateddatetime.utcnow() with timezone-aware alternative

  • Update string formatting to use f-strings

  • Remove Python 2 compatibility code


Changes diagram

flowchart LR  A["Python 2/3 compatibility code"] --> B["Python 3.9+ only code"]  C["datetime.utcnow()"] --> D["datetime.now(timezone.utc)"]  E["String format()"] --> F["f-strings"]  G["super(Class, self)"] --> H["super()"]
Loading

Changes walkthrough 📝

Relevant files
Enhancement
6 files
hello.py
Convert string formatting to f-strings                                     
+2/-2     
custom_log_format_request.py
Modernize super() calls                                                                   
+3/-3     
formatters.py
Remove Python 2 compatibility code                                             
+6/-9     
setup.py
Simplify file opening logic                                                           
+1/-1     
constants.py
Add Python 3.12 taskName attribute support                             
+9/-2     
handler.py
Use modern type hints                                                                       
+1/-1     
Formatting
8 files
__init__.py
Remove coding declaration                                                               
+0/-1     
__init__.py
Remove coding declaration                                                               
+0/-1     
__init__.py
Remove coding declaration                                                               
+0/-1     
__init__.py
Remove empty line                                                                               
+0/-1     
__init__.py
Remove coding declaration                                                               
+0/-1     
__init__.py
Remove coding declaration                                                               
+0/-1     
__init__.py
Remove coding declaration                                                               
+0/-1     
framework_base.py
Remove coding declaration                                                               
+0/-1     
Bug fix
3 files
dto.py
Fix datetime deprecation and super() calls                             
+3/-3     
util.py
Fix datetime deprecation and modernize class                         
+3/-4     
benmark_micro.py
Fix datetime deprecation warning                                                 
+2/-3     
Dependencies
1 files
code_quality.yml
Update GitHub Actions to latest versions                                 
+6/-6     

Need help?
  • Type/help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out thedocumentation for more information.
  • @qodo-code-review
    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Logic Error

    The Python 2/3 compatibility code has been incorrectly modified. The variableio_open is now assigned butio.open is no longer used, which will cause a NameError when Python version is not 3.

    io_open=open('README.rst',encoding="utf8")long_description=io_open.read()
    Compatibility Issue

    The version check for adding 'taskName' attribute only considers Python 3.12+, but the PR description mentions support for Python 3.9-3.12. This may cause inconsistent behavior across supported versions.

    ifsys.version_info.major==3andsys.version_info.minor>=12:_msg_attrs.append("taskName")

    Copy link

    @gemini-code-assistgemini-code-assistbot left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others.Learn more.

    Summary of Changes

    Hello@mavwolverine, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

    This pull request represents a significant modernization effort, primarily focused on updating the codebase to align with contemporary Python 3 best practices and remove outdated Python 2 compatibility constructs. The changes streamline syntax, enhance datetime handling for improved accuracy, and ensure forward compatibility with the latest Python versions.

    Highlights

    • Python Modernization: I've updated the codebase to leverage modern Python 3 features, including f-strings for string formatting, implicitsuper() calls, and contemporary type hinting syntax (e.g.,list[str] instead ofList[str]).
    • Python 2 Compatibility Removal: I've removed legacy Python 2 compatibility code, such as thesys.version_info checks forbasestring andstack_info, and the# coding=utf-8 headers which are no longer necessary in Python 3.
    • Timezone-Aware Datetime Handling: I've updated datetime operations to be timezone-aware, replacing deprecateddatetime.utcnow() withdatetime.now(timezone.utc) and ensuring epoch calculations are also timezone-aware.
    • Python 3.12 Compatibility: I've added conditional logic to include thetaskName attribute in expected log record attributes for Python 3.12 and newer, ensuring compatibility with recent Python versions.
    Using Gemini Code Assist

    The full guide for Gemini Code Assist can be found on ourdocumentation page, here are some quick tips.

    Invoking Gemini

    You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either/gemini <command> or@gemini-code-assist <command>. Below is a summary of the supported commands.

    FeatureCommandDescription
    Code Review/gemini reviewPerforms a code review for the current pull request in its current state.
    Pull Request Summary/gemini summaryProvides a summary of the current pull request in its current state.
    Comment@gemini-code-assistResponds in comments when explicitly tagged, both in issue comments and review comments.
    Help/gemini helpDisplays a list of available commands.

    Customization

    To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a.gemini/ folder in the base of the repository. Detailed instructions can be foundhere.

    Limitations & Feedback

    Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on@gemini-code-assist comments to provide feedback.

    You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with theGemini Code Assist IDE Extension.

    Footnotes

    1. Review thePrivacy Notices,Generative AI Prohibited Use Policy,Terms of Service, and learn how to configure Gemini Code Assist in GitHubhere. Gemini can make mistakes, so double check it anduse code with caution.

    @qodo-code-review
    Copy link

    qodo-code-reviewbot commentedJul 12, 2025
    edited
    Loading

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                   Impact
    General
    Fix timezone-aware epoch calculation

    The epoch calculation should use UTC timezone consistently. The current
    implementation may cause issues with timezone-aware datetime operations when
    comparing with other datetime objects.

    json_logging/util.py [73]

    +_epoch = datetime(1970, 1, 1, tzinfo=timezone.utc)-
    • Apply / Chat
    Suggestion importance[1-10]: 3

    __

    Why: The suggestion correctly identifies a positive change in the PR but offers no new improvement, as theimproved_code is identical to the code already present in the PR.

    Low
    Verify timezone consistency across codebase

    Usingdatetime.now(timezone.utc) is correct for timezone-aware UTC time.
    However, ensure this change is consistent with the rest of the codebase's
    datetime handling patterns.

    tests-performance/benmark_micro.py [5]

    +utcnow = datetime.now(timezone.utc)-
    • Apply / Chat
    Suggestion importance[1-10]: 3

    __

    Why: This suggestion correctly affirms the PR's change but only advises verifying consistency, which is a general good practice rather than a specific, actionable code improvement.

    Low
    • Update

    Copy link

    @gemini-code-assistgemini-code-assistbot left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others.Learn more.

    Code Review

    This pull request does a great job of modernizing the codebase by removing Python 2 compatibility code, updating to f-strings, and using timezone-aware datetimes. The changes are well-aligned with the goal of supporting Python 3.9+.

    I've found a few areas for improvement:

    • A critical issue inutil.py where a change to make_epoch timezone-aware will cause runtime errors in other parts of the code that have not been updated to pass timezone-aware datetimes.
    • An opportunity to simplify thesetup.py script by removing obsolete Python 2/3 compatibility logic.
    • A minor style improvement in a test helper for version checking.

    Please review my comments for details.



    _epoch=datetime(1970,1,1)
    _epoch=datetime(1970,1,1,tzinfo=timezone.utc)

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others.Learn more.

    critical

    Making_epoch a timezone-awaredatetime object is a good step towards modernizing the codebase. However, this change will cause aTypeError at runtime. The functionepoch_nano_second will now fail when called with a timezone-naivedatetime object, as it's not possible to subtract a naive from an aware datetime.

    For example,json_logging.formatters.BaseJSONFormatter._format_log_object calls it with a naive datetime:

    # json_logging/formatters.py:61utcnow=datetime.now(timezone.utc).replace(tzinfo=None)...# json_logging/formatters.py:65"written_ts":json_logging.util.epoch_nano_second(utcnow),

    To fix this, you need to ensure that all callers ofepoch_nano_second pass a timezone-awaredatetime object. The most direct fix would be to remove.replace(tzinfo=None) informatters.py, but that change is outside the scope of this diff. Please ensure all call sites are updated to prevent runtime failures.

    setup.py Outdated
    Comment on lines 7 to 11
    ifversion_info_major==3:
    long_description=open('README.rst',encoding="utf8").read()
    else:
    io_open=io.open('README.rst',encoding="utf8")
    io_open=open('README.rst',encoding="utf8")
    long_description=io_open.read()

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others.Learn more.

    medium

    Since this pull request drops support for Python 2 and targets Python 3.9+, this entireif/else block for version compatibility is no longer necessary. Theelse branch is now dead code.

    You can simplify this logic to directly read the file. Using awith statement is also recommended for handling files as it ensures they are closed properly even if errors occur.

    withopen('README.rst',encoding="utf8")asf:long_description=f.read()

    }
    ]

    ifsys.version_info.major==3andsys.version_info.minor>=12:

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others.Learn more.

    medium

    The version check can be made more concise and idiomatic by comparing thesys.version_info tuple directly. This improves readability and is the recommended way to perform version checks.

    Suggested change
    ifsys.version_info.major==3andsys.version_info.minor>=12:
    ifsys.version_info>= (3,12):

    @dwt
    Copy link

    dwt commentedJul 13, 2025

    I'm actually surprised that on the surface level the gemini code review looks rather sensible.

    @dwt
    Copy link

    dwt commentedJul 19, 2025

    @mavwolverine Do these suggestions by the AI make sense to you?

    @mavwolverine
    Copy link
    Author

    I'm actually surprised that on the surface level the gemini code review looks rather sensible.

    Yes, I was surprised too. How did you add it? Thanks

    @mavwolverine
    Copy link
    Author

    @mavwolverine Do these suggestions by the AI make sense to you?

    Yes, the suggestions do make sense, and it has covered areas I did not touch just based on the commit message. That is great!

    One thing I am unsure on is the timezone change#111 (comment)

    @mavwolverine
    Copy link
    Author

    It is suggesting "The most direct fix would be to remove .replace(tzinfo=None) in formatters.py", but it seems to be something added recently. So not sure on that.

    @mavwolverine
    Copy link
    Author

    Updated PR for other 2 suggestions

    @dwt
    Copy link

    dwt commentedJul 21, 2025

    @mavwolverine actually I didn't. I am pretty sure@bobbui did that. (Thanks for that@bobbui!).

    @dwt
    Copy link

    dwt commentedJul 26, 2025

    It is suggesting "The most direct fix would be to remove .replace(tzinfo=None) in formatters.py", but it seems to be something added recently. So not sure on that.

    Well, that was introduced to work around python 3.12 deprecations. Looking at the other function this callsiso_time_format that already appends aZ to the timestamp to mark it as ZULU/UTC, so the suggestion of gemini seems sensible for me?

    @dwt
    Copy link

    dwt commentedAug 19, 2025

    Friendly ping@mavwolverine - did you notice the feedback I gave you?

    Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

    Reviewers

    1 more reviewer

    @gemini-code-assistgemini-code-assist[bot]gemini-code-assist[bot] left review comments

    Reviewers whose approvals may not affect merge requirements

    Assignees

    No one assigned

    Projects

    None yet

    Milestone

    No milestone

    Development

    Successfully merging this pull request may close these issues.

    2 participants

    @mavwolverine@dwt

    [8]ページ先頭

    ©2009-2025 Movatter.jp