Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misleading __version__ attribute of modules in standard library #76007

Open
abukaj mannequin opened this issue Oct 20, 2017 · 11 comments
Open

Misleading __version__ attribute of modules in standard library #76007

abukaj mannequin opened this issue Oct 20, 2017 · 11 comments
Labels
3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@abukaj
Copy link
Mannequin

abukaj mannequin commented Oct 20, 2017

BPO 31826
Nosy @warsaw, @rhettinger, @ncoghlan, @pitrou, @merwok, @encukou, @serhiy-storchaka, @abukaj, @cryvate
PRs
  • bpo-31826: remove unused __version__ from mock.py #17977
  • 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 = None
    created_at = <Date 2017-10-20.13:21:04.010>
    labels = ['3.7', 'type-bug', 'library']
    title = 'Misleading __version__ attribute of modules in standard library'
    updated_at = <Date 2020-02-04.10:54:36.743>
    user = 'https://github.com/abukaj'

    bugs.python.org fields:

    activity = <Date 2020-02-04.10:54:36.743>
    actor = 'cryvate'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2017-10-20.13:21:04.010>
    creator = 'abukaj'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31826
    keywords = ['patch']
    message_count = 7.0
    messages = ['304654', '304763', '304765', '304779', '304780', '304823', '361340']
    nosy_count = 9.0
    nosy_names = ['barry', 'rhettinger', 'ncoghlan', 'pitrou', 'eric.araujo', 'petr.viktorin', 'serhiy.storchaka', 'abukaj', 'cryvate']
    pr_nums = ['17977']
    priority = 'normal'
    resolution = None
    stage = 'needs patch'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue31826'
    versions = ['Python 3.7']

    @abukaj
    Copy link
    Mannequin Author

    abukaj mannequin commented Oct 20, 2017

    Several modules of the standard library (at least re and csv) have __version__ strings.

    The string is the same for Python 2.7-3.6:

        >>> import re, csv; print(re.__version__, csv.__version__)
        2.2.1 1.0

    while documentation indicates changes in the modules.

    Semantic versioning (recommended by PEP-440) suggests that at least minor version should change in such case.

    I suspect it to be a "code fossil" which may be removed according to PEP-396.

    @abukaj abukaj mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Oct 20, 2017
    @terryjreedy terryjreedy added the 3.7 (EOL) end of life label Oct 20, 2017
    @rhettinger
    Copy link
    Contributor

    I would support just removing the version attributes for csv and re.

    @pitrou
    Copy link
    Member

    pitrou commented Oct 22, 2017

    +1 for removing __version__ on all stdlib modules which are not externally maintained.

    @ncoghlan
    Copy link
    Contributor

    +1 from me for dropping these, and noting which modules were affected in the Porting section of the 3.7 What's New (I'd be surprised if anyone was depending on them existing, but it doesn't hurt to mention it, and may help if someone is trying to figure out what changed)

    @rhettinger
    Copy link
    Contributor

    Please do leave version in the decimal module where it has a precise meaning, tracking a particular version of the spec that was implemented and tested.

    @merwok
    Copy link
    Member

    merwok commented Oct 23, 2017

    The version in distutils is derived from sys.version and should be left as is too. Thanks!

    @encukou
    Copy link
    Member

    encukou commented Feb 4, 2020

    PR for removing __version__ from mock: #17977

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @furkanonder
    Copy link
    Contributor

    @encukou The issue seems to have been resolved. Can we close the issue?

    @encukou
    Copy link
    Member

    encukou commented May 15, 2023

    There are still a lot of modules with __version__
    IMO, to resolve it properly:

    • There should be a test, similar to test___all__, to avoid regressions
    • For modules where __version__ has a meaning, that fact should be documented -- either we want users to use it, or there's no point exposing it

    Note that nowadays, the proper way to remove an attribute is with a deprecation period using module __getattr__.

    @smontanaro
    Copy link
    Contributor

    smontanaro commented Jan 17, 2024

    I just migrated __version__ from _csv.c to csv.py. I was unaware of this discussion. I'm happy to remove it altogether. Can someone explain to me how this trend came about? I was a bit surprised to see it at all w.r.t. the csv module.

    @erlend-aasland
    Copy link
    Contributor

    Note that nowadays, the proper way to remove an attribute is with a deprecation period using module __getattr__.

    Related issue:

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    9 participants