Skip to content

Comments

Fix mypy strict mode and ruff lint errors#3

Merged
harumaki4649 merged 3 commits intomainfrom
copilot/fix-mypy-lint-errors
Jan 24, 2026
Merged

Fix mypy strict mode and ruff lint errors#3
harumaki4649 merged 3 commits intomainfrom
copilot/fix-mypy-lint-errors

Conversation

Copy link
Contributor

Copilot AI commented Jan 24, 2026

CI was failing on tox -e lint and tox -e type due to missing type annotations and style violations.

Changes

Type annotations (mypy --strict compliance):

  • Added return type annotations to all methods (-> None for __init__, specific types for others)
  • Fixed implicit Optional by explicitly typing defaults: data: Optional[Dict[str, Any]] = None
  • Added generic type parameters: Dict[str, Any], List[Any], Type[Any]
  • Added cast() calls where _validate_base() returns lose type specificity
  • Resolved name shadowing: used builtins.str in type hints within VBuilder class to disambiguate from the str() method

Linting (ruff compliance):

  • Removed unused imports and variables
  • Changed type comparisons from == to is for built-in types
  • Split colon-separated statements onto separate lines
  • Removed unused exception captures

Technical Note

The name shadowing issue was subtle - mypy correctly flagged that Dict[str, Any] within the VBuilder class scope could ambiguously refer to either the built-in str type or the VBuilder.str() method:

class VBuilder:
    def str(self) -> StringValidator:  # This shadows built-in str
        return StringValidator()
    
    # mypy sees 'str' here as potentially referring to the method above
    def list(self, item_validator: Union[Validator, Dict[str, Any], Type[Any]]) -> ListValidator:
        #                                                    ^^^

Using builtins.str explicitly resolves the ambiguity.

Original prompt

This section details on the original issue you should resolve

<issue_title>ci.ymlでmypyとlintのエラーの対処をしてください</issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits January 24, 2026 04:01
Co-authored-by: harumaki4649 <83683593+harumaki4649@users.noreply.github.com>
Co-authored-by: harumaki4649 <83683593+harumaki4649@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix mypy and lint errors in ci.yml Fix mypy strict mode and ruff lint errors Jan 24, 2026
Copilot AI requested a review from harumaki4649 January 24, 2026 04:05
@harumaki4649 harumaki4649 marked this pull request as ready for review January 24, 2026 04:05
@harumaki4649 harumaki4649 merged commit 305ac04 into main Jan 24, 2026
24 checks passed
@harumaki4649 harumaki4649 deleted the copilot/fix-mypy-lint-errors branch January 24, 2026 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci.ymlでmypyとlintのエラーの対処をしてください

2 participants