fix: resolve mypy 2.3 type errors (unblocks dependabot #1821)#1826
Open
jacalata wants to merge 3 commits into
Open
fix: resolve mypy 2.3 type errors (unblocks dependabot #1821)#1826jacalata wants to merge 3 commits into
jacalata wants to merge 3 commits into
Conversation
Bumps [mypy](https://github.com/python/mypy) from 1.4 to 2.3.0. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](python/mypy@v1.4.0...v2.3.0) --- updated-dependencies: - dependency-name: mypy dependency-version: 2.3.0 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com>
- strings.py: cast tostring() return value to T since mypy 2.3 no longer accepts bytes as compatible with TypeVar T constrained to str|bytes - test_datasource.py: add explicit `import unittest.mock` since mypy 2.3 no longer resolves submodule attributes through the parent import Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The bytes overload was passing bytearray to _redact_any_type whose TypeVar T is constrained to str|bytes. mypy 2.3 correctly rejects bytearray as Sequence[int]. Fix: pass bytes directly and cast the return value for both call sites. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two type errors surfaced by mypy 2.3 (dependabot PR #1821):
tableauserverclient/helpers/strings.py:42tostring()returnsbytesregardless of theTtype variable constraint. mypy 2.3 correctly rejects this. Fix:cast(T, tostring(...))since the two call sites passencoding="unicode"forstrandNoneforbytes, making the cast always correct at runtime.test/test_datasource.py:580unittest.mock.patch.objectwas used withoutimport unittest.mock— onlyimport unittestwas present. mypy 2.3 no longer resolves submodule attributes through the parent import. Fix: add explicitimport unittest.mock.Test plan
mypy tableauserverclient/helpers/strings.py test/test_datasource.pypassespytest test/test_datasource.pypasses (55 tests)🤖 Generated with Claude Code