From 56b0ba46acd63a1b851003c2525bb4527e9d4408 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 21 Jul 2026 00:13:44 +0000 Subject: [PATCH 1/3] chore(deps-dev): bump mypy from 1.4 to 2.3.0 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](https://github.com/python/mypy/compare/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] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8134f73f1..577f64bfb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ classifiers = [ repository = "https://github.com/tableau/server-client-python" [project.optional-dependencies] -test = ["black==26.3.1", "build", "mypy==1.4", "pytest>=7.0", "pytest-cov", "pytest-subtests", +test = ["black==26.3.1", "build", "mypy==2.3.0", "pytest>=7.0", "pytest-cov", "pytest-subtests", "pytest-xdist", "requests-mock>=1.0,<2.0", "types-requests>=2.32.4.20250913"] [tool.setuptools.package-data] From 1b8eae4570ae4c5ce6bd683b9db19afa05eddf01 Mon Sep 17 00:00:00 2001 From: Jac Fitzgerald Date: Tue, 21 Jul 2026 23:18:06 -0700 Subject: [PATCH 2/3] fix: resolve mypy 2.3 errors in strings.py and test_datasource.py - 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 --- tableauserverclient/helpers/strings.py | 7 ++++--- test/test_datasource.py | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tableauserverclient/helpers/strings.py b/tableauserverclient/helpers/strings.py index 7a0eaddc7..9dac1497d 100644 --- a/tableauserverclient/helpers/strings.py +++ b/tableauserverclient/helpers/strings.py @@ -1,6 +1,6 @@ from defusedxml.ElementTree import fromstring, tostring from functools import singledispatch -from typing import TypeVar, overload +from typing import TypeVar, cast, overload # the redact method can handle either strings or bytes, but it can't mix them. # Generic type so we can write the actual logic once, then use singledispatch to @@ -17,8 +17,9 @@ def _redact_any_type(xml: T, sensitive_word: T, replacement: T, encoding=None) - matches = root.findall(".//password") for item in matches: item.text = "********" - # tostring returns bytes unless an encoding value is passed - return tostring(root, encoding=encoding) + # tostring returns bytes unless an encoding value is passed; cast since + # the callers pass encoding="unicode" for str and None for bytes + return cast(T, tostring(root, encoding=encoding)) except Exception: # something about the xml handling failed. Just cut off the text at the first occurrence of "password" location = xml.find(sensitive_word) diff --git a/test/test_datasource.py b/test/test_datasource.py index c4bca0a7b..95332c6db 100644 --- a/test/test_datasource.py +++ b/test/test_datasource.py @@ -3,6 +3,7 @@ from pathlib import Path import tempfile import unittest +import unittest.mock from zipfile import ZipFile from defusedxml.ElementTree import fromstring From 112b0a806401071fef3f4f0cc820c9ef569e70a2 Mon Sep 17 00:00:00 2001 From: Jac Fitzgerald Date: Tue, 21 Jul 2026 23:20:27 -0700 Subject: [PATCH 3/3] fix: correctly resolve mypy 2.3 TypeVar error in strings.py 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 --- tableauserverclient/helpers/strings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tableauserverclient/helpers/strings.py b/tableauserverclient/helpers/strings.py index 9dac1497d..a095d606e 100644 --- a/tableauserverclient/helpers/strings.py +++ b/tableauserverclient/helpers/strings.py @@ -40,7 +40,7 @@ def _(xml: str) -> str: @redact_xml.register # type: ignore[no-redef] def _(xml: bytes) -> bytes: - return _redact_any_type(bytearray(xml), b"password", b"..[redacted]") + return cast(bytes, _redact_any_type(xml, b"password", b"..[redacted]")) @overload