Skip to content
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

[py] moved mypy settings from mypy.ini to pyproject.toml #14253

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

sandeepsuryaprasad
Copy link
Contributor

@sandeepsuryaprasad sandeepsuryaprasad commented Jul 11, 2024

User description

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Moved all mypy settings from mypy.ini file to pyproject.toml.

Motivation and Context

All mypy configurations can be accommodated in pyproject.toml file. This eliminates a separate configuration file for mypy settings.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Enhancement, Configuration changes


Description

  • Moved all mypy settings from mypy.ini to pyproject.toml.
  • Removed the mypy.ini file.
  • Added global and module-specific mypy configurations to pyproject.toml.

Changes walkthrough 📝

Relevant files
Configuration changes
mypy.ini
Removed `mypy.ini` configuration file                                       

py/mypy.ini

  • Removed the entire mypy.ini configuration file.
+0/-39   
pyproject.toml
Added mypy settings to `pyproject.toml`                                   

py/pyproject.toml

  • Added mypy settings to pyproject.toml.
  • Included global and module-specific mypy options.
  • +42/-0   

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified

    Copy link
    Contributor

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Enable warnings for unreachable code after type analysis

    Consider setting warn_unreachable to True to enable warnings for unreachable code
    after type analysis, which can help identify logical errors or redundant code.

    py/pyproject.toml [36]

    -warn_unreachable = False
    +warn_unreachable = True
     
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Setting warn_unreachable to True helps identify logical errors or redundant code, which can improve code quality and maintainability.

    8
    Best practice
    Enable type enforcement on all function definitions

    Consider enabling disallow_untyped_defs to enforce type annotations on all
    functions. This can significantly improve code quality and maintainability by
    ensuring that all functions are properly typed.

    py/pyproject.toml [20]

    -disallow_untyped_defs = False
    +disallow_untyped_defs = True
     
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Enabling disallow_untyped_defs can improve code quality and maintainability by ensuring all functions are properly typed. However, it may require significant refactoring if the codebase has many untyped functions.

    7
    Prevent untyped function calls from typed functions

    Enable disallow_untyped_calls to prevent calling functions without type annotations
    from typed functions, enhancing the reliability and type-safety of the code.

    py/pyproject.toml [18]

    -disallow_untyped_calls = False
    +disallow_untyped_calls = True
     
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Enabling disallow_untyped_calls enhances the reliability and type-safety of the code, but it may require extensive changes if there are many untyped function calls in the codebase.

    7
    Ensure complete type annotations for functions

    It's recommended to enable disallow_incomplete_defs to ensure that all functions
    with type annotations are fully annotated, promoting more robust type checking.

    py/pyproject.toml [22]

    -disallow_incomplete_defs = False
    +disallow_incomplete_defs = True
     
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Enabling disallow_incomplete_defs promotes more robust type checking by ensuring all functions with type annotations are fully annotated. This can improve code reliability but may require additional effort to fully annotate existing functions.

    7

    @sandeepsuryaprasad
    Copy link
    Contributor Author

    @diemol can you please trigger the workflow for this PR.

    1 similar comment
    @sandeepsuryaprasad
    Copy link
    Contributor Author

    @diemol can you please trigger the workflow for this PR.

    @sandeepsuryaprasad
    Copy link
    Contributor Author

    @diemol @AutomatedTester can you please review this PR and trigger the workflow..

    @sandeepsuryaprasad
    Copy link
    Contributor Author

    @diemol there are some tests failing (BiDi) which i think are not related to the configuration changes that i have made for mypy in pyproject.toml can you please help me out in this. Thanks.

    @sandeepsuryaprasad
    Copy link
    Contributor Author

    @diemol can you please merge this PR. The tests that are failing are not due to the changes that i have made in this PR.

    @VietND96 VietND96 added the C-py label Oct 25, 2024
    @AutomatedTester AutomatedTester merged commit 6b40d9e into SeleniumHQ:trunk Oct 28, 2024
    12 of 13 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    4 participants