GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Deprecate the typing.io and typing.re pseudo-modules · Issue #82472 · python/cpython

Deprecate the typing.io and typing.re pseudo-modules #82472

New issue
Copy link
New issue
Copy link
Closed
Closed
Deprecate the typing.io and typing.re pseudo-modules#82472
Copy link
Labels
3.11only security fixesonly security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

dgelessus
mannequin
opened on Sep 27, 2019
Issue body actions
BPO 38291
Nosy @gvanrossum, @srittau, @ambv, @serhiy-storchaka, @ilevkivskyi, @JelleZijlstra, @miss-islington, @tirkarthi, @dgelessus, @Fidget-Spinner
PRs
  • bpo-38291: Remove mention of typing.io and typing.re again #26113
  • bpo-38291: DeprecationWarning when importing typing.{io,re} #26719
  • [3.10] bpo-38291: Remove mention of typing.io and typing.re again (GH-26113) #26720
  • [3.9] bpo-38291: Remove mention of typing.io and typing.re again (GH-26113) #26721
  • bpo-38291: Reset DeprecationWarning filters in test_typing io and re #26811
  • bpo-38291: Fix a spurious warning when using help(object) #27039
  • bpo-38291: Fix a deprecation warning in typing tests #27312
  • bpo-38291: Update 3.10 WhatsNew with typing.{io|re} DeprecationWarning #27872
  • [3.10] bpo-38291: Update 3.10 WhatsNew with typing.{io|re} DeprecationWarning (GH-27872) #27907
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-07-24.04:12:34.707>
    created_at = <Date 2019-09-27.11:48:37.318>
    labels = ['3.11', 'type-bug', 'library', 'docs']
    title = 'Deprecate the typing.io and typing.re pseudo-modules'
    updated_at = <Date 2021-08-23.17:32:39.463>
    user = 'https://github.com/dgelessus'

    bugs.python.org fields:

    activity = <Date 2021-08-23.17:32:39.463>
    actor = 'miss-islington'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-07-24.04:12:34.707>
    closer = 'kj'
    components = ['Documentation', 'Library (Lib)']
    creation = <Date 2019-09-27.11:48:37.318>
    creator = 'dgelessus'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 38291
    keywords = ['patch']
    message_count = 28.0
    messages = ['353356', '353400', '392730', '393611', '393613', '395794', '395800', '395803', '395805', '396147', '396183', '396217', '396219', '396317', '396322', '396324', '396968', '396975', '397001', '397012', '397013', '397016', '397018', '397020', '397042', '398082', '400151', '400152']
    nosy_count = 11.0
    nosy_names = ['gvanrossum', 'srittau', 'docs@python', 'lukasz.langa', 'serhiy.storchaka', 'levkivskyi', 'JelleZijlstra', 'miss-islington', 'xtreak', 'dgelessus', 'kj']
    pr_nums = ['26113', '26719', '26720', '26721', '26811', '27039', '27312', '27872', '27907']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue38291'
    versions = ['Python 3.11']

    Activity

    Next
    1. dgelessus commented on Sep 27, 2019

      @dgelessus
      dgelessusmannequin
      on Sep 27, 2019
      MannequinAuthor
      More actions

      According to bpo-35089 (and the GitHub issues linked there), the typing.io and typing.re modules should no longer be used. Starting with Python 3.6, the typing documentation no longer mentions the typing.io and typing.re modules, and instead documents their contents as part of the main typing module.

      However, the typing module at runtime still supports typing.io and typing.re as before. Since these modules are not meant to be used anymore and are no longer documented, I would expect at least a DeprecationWarning when using them at runtime.

      The documentation on this could also be a bit clearer. As long as the modules are still supported at runtime, I would expect the documentation to mention that they still exist, but shouldn't be used anymore. In its current state, the documentation is confusing when coming from Python 3.5 (where typing.io and typing.re were the only documented way to access IO, Pattern, etc., but accessing typing.IO and typing.Pattern directly also works at runtime).

    2. dgelessus
      added
      3.7 (EOL)end of lifeend of life
      3.8 (EOL)end of lifeend of life
      3.9 (EOL)end of lifeend of life
      on Sep 27, 2019
    3. dgelessus
      assigned
      docspython
      on Sep 27, 2019
    4. dgelessus
      added
      docsDocumentation in the Doc dirDocumentation in the Doc dir
      stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
      on Sep 27, 2019
    5. ilevkivskyi commented on Sep 27, 2019

      @ilevkivskyi
      ilevkivskyi
      on Sep 27, 2019
      Member
      More actions

      Guido, what is your final opinion on this?

    6. JelleZijlstra commented on May 2, 2021

      @JelleZijlstra
      JelleZijlstra
      on May 2, 2021
      Member
      More actions

      The documentation (https://docs.python.org/3.10/library/typing.html#typing.BinaryIO) now mentions the typing.io and typing.re namespaces.

      I would prefer that they be deprecated and eventually completely removed. They don't work with most static type checkers. https://bugs.python.org/issue42001 makes the same points.

    7. JelleZijlstra
      added
      3.10 (EOL)end of lifeend of life
      3.11only security fixesonly security fixes
      and removed
      3.7 (EOL)end of lifeend of life
      3.8 (EOL)end of lifeend of life
      3.9 (EOL)end of lifeend of life
      on May 2, 2021
    8. 19 remaining items

    9. srittau commented on Jul 5, 2021

      @srittau
      srittaumannequin
      on Jul 5, 2021
      Mannequin
      More actions

      We could easily do what Ken did in PR-26811, and add "warnings.filterwarnings("default", category=DeprecationWarning)" to the test, but I would like to understand what is going on first. It seems the warnings are generated by test_builtin_with_more_than_four_children, which doesn't operate on typing directly. Here is a repro, without tests:

      srittau@blitz:~/Projekte/cpython (typing-io *)$ ./python -Wall
      Python 3.11.0a0 (heads/main:17f94e2888, Jul  5 2021, 19:19:04) [GCC 8.3.0] on linux
      Type "help", "copyright", "credits" or "license" for more information.
      >>> import pydoc
      >>> import typing
      >>> doc = pydoc.TextDoc()
      >>> x = doc.docclass(object)
      /home/srittau/Projekte/cpython/Lib/pydoc.py:1344: DeprecationWarning: typing.io is deprecated, import directly from typing instead. typing.io will be removed in Python 3.12.
        if not cls.__name__.startswith("_") and cls.__module__ == "builtins"),
      /home/srittau/Projekte/cpython/Lib/pydoc.py:1344: DeprecationWarning: typing.re is deprecated, import directly from typing instead. typing.re will be removed in Python 3.12.
        if not cls.__name__.startswith("_") and cls.__module__ == "builtins"),
      >>> 

      Same warning when calling "help(object)". This is not great. I assume that it is somehow related to pydoc.docclass() iterating over the the items of typing, but only if typing was imported. Please not that "io" and "re" are not part of typing.__all__.

      I will investigate more.

    10. srittau commented on Jul 5, 2021

      @srittau
      srittaumannequin
      on Jul 5, 2021
      Mannequin
      More actions

      pr-27039 suppresses warnings when accessing typing.{re,io}.__module__, which should fix this warning.

    11. gvanrossum commented on Jul 5, 2021

      @gvanrossum
      gvanrossum
      on Jul 5, 2021
      Member
      More actions

      Why not just change "typing.io" to "typing"?

    12. srittau commented on Jul 5, 2021

      @srittau
      srittaumannequin
      on Jul 5, 2021
      Mannequin
      More actions

      typing.io is not referenced in either the tests or the implementation for pydoc. What happens is basically: typing.io is a class, so its derived from object. When formatting the docstring for object, the formatter queries the __module__ attribute of all sub-classes of object, including typing.io, so that it can include the sub-classes in its output:

      --------------

      Help on class object in module builtins:

      class object
      | The base class of the class hierarchy.
      |
      | When called, it accepts no arguments and returns a new featureless
      | instance that has no instance attributes and cannot be given any.
      |
      | Built-in subclasses:
      | anext_awaitable
      | async_generator
      | async_generator_asend
      | async_generator_athrow
      | ... and 88 other subclasses
      |
      [...]

      --------------

      Before the PR this failed, as accessing any typing.io.__module__ printed the warning.

    13. gvanrossum commented on Jul 5, 2021

      @gvanrossum
      gvanrossum
      on Jul 5, 2021
      Member
      More actions

      Thanks for the explanation. Let's reopen the issue for now.

    14. gvanrossum
      reopened this on Jul 5, 2021
    15. gvanrossum commented on Jul 6, 2021

      @gvanrossum
      gvanrossum
      on Jul 6, 2021
      Member
      More actions

      New changeset 8b849ea by Sebastian Rittau in branch 'main':
      bpo-38291: Fix a spurious warning when using help(object) (bpo-27039)
      8b849ea

    16. gvanrossum
      closed this as completedon Jul 6, 2021
    17. serhiy-storchaka commented on Jul 23, 2021

      @serhiy-storchaka
      serhiy-storchaka
      on Jul 23, 2021
      Member
      More actions

      Currently deprecation warnings are emitted in test_typing:

      $ ./python -m test test_typing
      0:00:00 load avg: 3.38 Run tests sequentially
      0:00:00 load avg: 3.38 [1/1] test_typing
      /home/serhiy/py/cpython/Lib/test/test_typing.py:4657: DeprecationWarning: typing.io is deprecated, import directly from typing instead. typing.io will be removed in Python 3.12.
        k not in typing.io.__all__ and
      /home/serhiy/py/cpython/Lib/test/test_typing.py:4658: DeprecationWarning: typing.re is deprecated, import directly from typing instead. typing.re will be removed in Python 3.12.
        k not in typing.re.__all__ and

      == Tests result: SUCCESS ==

      1 test OK.

      Total duration: 564 ms
      Tests result: SUCCESS

    18. serhiy-storchaka
      reopened this on Jul 23, 2021
    19. serhiy-storchaka
      unassigned
      docspython
      on Jul 23, 2021
    20. Fidget-Spinner
      closed this as completedon Jul 24, 2021
    21. ambv commented on Aug 23, 2021

      @ambv
      ambv
      on Aug 23, 2021
      Contributor
      More actions

      New changeset 1a995b0 by Ken Jin in branch 'main':
      bpo-38291: Update 3.10 WhatsNew with typing.{io|re} DeprecationWarning (GH-27872)
      1a995b0

    22. miss-islington commented on Aug 23, 2021

      @miss-islington
      miss-islington
      on Aug 23, 2021
      Contributor
      More actions

      New changeset 27f2f62 by Miss Islington (bot) in branch '3.10':
      bpo-38291: Update 3.10 WhatsNew with typing.{io|re} DeprecationWarning (GH-27872)
      27f2f62

    23. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    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

      3.11only security fixesonly security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

        You are visitor 01402503 — GeezerVison does not store the pages you look up.
        Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.