Skip to content

Stubs and use of @deprecated names #18007

Closed

Description

@JelleZijlstra

Running stubtest from mypy main on typeshed produces:

error: not checking stubs due to mypy build errors:
stdlib/asyncio/events.pyi:23: note: class asyncio.unix_events.AbstractChildWatcher is deprecated: Deprecated as of Python 3.12; will be removed in Python 3.14  [deprecated]
stdlib/unittest/__init__.pyi:53: note: function unittest.loader.findTestCases is deprecated: Deprecated in Python 3.11; removal scheduled for Python 3.13  [deprecated]
stdlib/unittest/__init__.pyi:53: note: function unittest.loader.getTestCaseNames is deprecated: Deprecated in Python 3.11; removal scheduled for Python 3.13  [deprecated]
stdlib/unittest/__init__.pyi:53: note: function unittest.loader.makeSuite is deprecated: Deprecated in Python 3.11; removal scheduled for Python 3.13  [deprecated]

Which is not very useful. Maybe we should suppress deprecated in typeshed's configuration or in stubtest in general.

Activity

  1. JelleZijlstra commented on Oct 21, 2024

    @JelleZijlstra
    MemberAuthor

    (I added a topic-pep-702 label, @tyralla fyi.)

  2. hauntsaninja commented on Oct 21, 2024

    @hauntsaninja
    Collaborator

    I think suppressing all deprecated errors in stubs could make sense

  3. JelleZijlstra commented on Oct 22, 2024

    @JelleZijlstra
    MemberAuthor

    I feel that might be too much; if we deprecate something in _typeshed, we'd want mypy to tell stub authors about it.

  4. hauntsaninja commented on Oct 22, 2024

    @hauntsaninja
    Collaborator

    We could just special case typeshed stubs in particular then (mypy already does this in a few places)

    (And in general that feels niche / for type-only programs removals don't feel too much more disruptive than deprecations)

  5. tyralla commented on Oct 22, 2024

    @tyralla
    Collaborator

    Do you mean just extending the current warn_deprecated method like this?

        def warn_deprecated(self, node: SymbolNode | None, context: Context) -> None:
            """Warn if deprecated."""
            if isinstance(node, Decorator):
                node = node.func
            if isinstance(node, (FuncDef, OverloadedFuncDef, TypeInfo)) and (
                (deprecated := node.deprecated) is not None
            ) and not self.is_typeshed_stub:  # !!!
                warn = self.msg.fail if self.options.report_deprecated_as_error else self.msg.note
                warn(deprecated, context, code=codes.DEPRECATED)

    If so (and if it works, not checked so far), I could modify PR #17926 accordingly, which still suffers under typeshed issues.

    (Thanks for the new label, @JelleZijlstra.)

  6. hauntsaninja commented on Oct 22, 2024

    @hauntsaninja
    Collaborator

    Yup!

  7. tyralla commented on Oct 22, 2024

    @tyralla
    Collaborator

    Seems I am starting to learn some Mypy slang ;-)

  8. tyralla commented on Nov 1, 2025

    @tyralla
    Collaborator

    Done as decided in #17926 a long time ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions