Open
Conversation
The rule name ``non-subscriptable`` is not recognised by ty, so the intended suppression has no effect. This causes 15 ``not-subscriptable`` errors and 1 ``unknown-rule`` warning in every CI run (cf. sphinx-doc#14238).
non-subscriptable → not-subscriptable- Suppress ``unused-type-ignore-comment`` in ty.toml; these ``# type: ignore`` comments are needed by mypy. - Remove six stale ``# ty: ignore`` directives for issues that ty has since fixed. - Add targeted ``# ty: ignore`` comments for five false positives that stem from ty inference limitations. Together with the previous commit, this brings the ty diagnostic count from 312 to 0. Ref: sphinx-doc#14238
f9006b9 to
126205e
Compare
Python 3.15 added ``_check_help()`` to ``argparse.ArgumentParser`` which calls ``re.sub()`` during ``add_argument()``. The C implementation of ``re.sub()`` requires actual ``str`` objects, so it rejects ``_TranslationProxy`` with ``TypeError``. Fix by inheriting from ``str``: - ``str.__new__`` stores the untranslated message as the base buffer - All dunder methods still delegate to the *translated* text - C-level operations see a valid ``str`` and succeed - Replace ``__getstate__``/``__setstate__``/``__copy__`` with ``__reduce__`` (the standard mechanism for ``str`` subclasses)
- Suppress FURB189 (no viable UserString alternative for C-level checks) - Fix PYI034: return `Self` from `__new__` instead of concrete class - Fix ARG004: prefix unused `__new__` params with `_` - Fix mypy overrides: widen `__contains__` to `object`, `__getitem__` to `SupportsIndex | slice` to satisfy Liskov substitution - Remove stale `type: ignore[return-value]` (now a `str` subclass)
- Collapse `__new__` to one line and match parameter names with `__init__` (pyright) - Suppress ruff ARG004 for `__new__` (params needed to match `__init__` for pyright) - Accept `object` in `__contains__` to satisfy LSP (mypy override check) with isinstance guard for type narrowing - Revert `__contains__` char type for ty/mypy compatibility
abf4b34 to
fbf55aa
Compare
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
The ty CI check currently reports 312 diagnostics, causing every PR to
show a failing check. This PR resolves all of them:
Fix typo in ty.toml (
non-subscriptable→not-subscriptable)so the existing suppression rule takes effect (-16 diagnostics).
Suppress
unused-type-ignore-commentin ty.toml. These# type: ignorecomments are required by mypy; ty should not warnabout them (-288 diagnostics).
Remove six stale
# ty: ignoredirectives for issues that tyhas since fixed (-6 diagnostics):
sphinx/builders/xml.py—unresolved-attributesphinx/util/docutils.py—unresolved-importsphinx/util/parallel.py—unresolved-attributetests/test_builders/xpath_util.py—no-matching-overload(ty#117)tests/test_intl/test_intl.py—missing-argument(ty#1787)tests/test_transforms/test_transforms_post_transforms.py—invalid-return-typeAdd targeted
# ty: ignorefor five false positives caused byty inference limitations (+5 inline suppressions, -5 diagnostics):
sphinx/ext/apidoc/_generate.py—unsupported-operator(sorted → Sized)sphinx/util/matching.py—no-matching-overload(filter + re.match)tests/test_ext_intersphinx/test_ext_intersphinx.py—not-iterabletests/test_util/test_util_inspect.py—invalid-type-formtests/test_util/test_util_typing.py—invalid-type-form(×2)Net result: 312 → 0 diagnostics.
Ref: #14238
Test plan
tyCI check passes with zero diagnostics