Skip to content

Conversation

@smontanaro
Copy link
Contributor

@smontanaro smontanaro commented Jan 16, 2024

@smontanaro
Copy link
Contributor Author

I don't think this requires a News entry. In theory, the _csv module is an implementation detail. Nothing changed when asking for csv.__doc__.

@smontanaro
Copy link
Contributor Author

Not sure who the default documentation reviewer is. I suspect @encukou will know...

Copy link
Member

@AA-Turner AA-Turner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine but I'm not a csv expert!

A

@AA-Turner
Copy link
Member

Thoughts on backports? I'm somewhat tempted, as future changes to the CSV docstring will be much harder if this PR isn't backported.

A

@smontanaro
Copy link
Contributor Author

smontanaro commented Jan 16, 2024 via email

@AA-Turner AA-Turner added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Jan 16, 2024
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this change needs a NEWS entry, because it has a user visible effect in public module (for example removing "__doc__" from __all__).

And while we are here, why not remove also "__version__" from __all__?

@smontanaro
Copy link
Contributor Author

@serhiy-storchaka Thanks, I'll take care of both later today.

@erlend-aasland
Copy link
Contributor

@serhiy-storchaka, some code may rely on __version__. I think this PR should focus on the docstring only. See previous more or less relevant discussions:

@smontanaro
Copy link
Contributor Author

I didn't see @erlend-aasland's note about creeping __version__ism. That said, I'm happy to remove it from the csv module altogether if that's what folks want. Maybe someone relies on it, but I'd be kinda surprised. In any case, it doesn't belong in __all__ (IMO), and there's no need to define it in C code just to import it into the front-end Python module.

Removing __version__ shouldn't be backported though. If removing it is the path forward, I should probably do it in a second PR which isn't going to be backported.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, besides niypicks about a NEWS file.

Comment on lines 1418 to 1421
def test__all__(self):
extra = {'__doc__', '__version__'}
support.check__all__(self, csv, ('csv', '_csv'), extra=extra)

Copy link
Member

@AA-Turner AA-Turner Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think test__all__ should be kept?

Suggested change
def test__all__(self):
extra = {'__doc__', '__version__'}
support.check__all__(self, csv, ('csv', '_csv'), extra=extra)
def test__all__(self):
support.check__all__(self, csv, {'csv', '_csv'})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AA-Turner Isn't test__all__ a standard thing? Why is this override needed if we no longer have an extra?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test.support.check__all__() is, but test__all__ isn't defined in unittest.TestCase, so we do need to define the test to keep it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is not overridden, it is added. It compares the __all__ content with the calculated expected value (all public function, classes, etc defined in the specified modules). extra is an extra.

@smontanaro
Copy link
Contributor Author

Before anybody merges (not my job), let's settle on the fate of csv.__version__.

@AA-Turner
Copy link
Member

AA-Turner commented Jan 17, 2024

No objection to removing csv.__version__, but I think it should be done in a new PR with a proper deprecation, which wouldn't block this PR's goal of moving __version__ to csv.py (and indeed, having __version__ defined in Python would make the deprecation mildly easier).

_deprecated___version__ = "1.0"

def __getattr__(name):
    if name == "__version__":
        from warnings import _deprecated

        _deprecated(name, remove=(3, 15))
        return globals()[f"_deprecated_{name}"]
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

A

@erlend-aasland
Copy link
Contributor

The fate of __version__ lies in another issue and PR. We can use #76007 for the issue, as csv is already mentioned there.

@smontanaro
Copy link
Contributor Author

No objection to removing csv.__version__, but I think it should be done in a new PR with a proper deprecation, which wouldn't block this PR's goal of moving __version__ to csv.py (and indeed, having __version__ defined in Python would make the deprecation mildly easier).

_deprecated___version__ = "1.0"

def __getattr__(name):
    if name == "__version__":
        from warnings import _deprecated

        _deprecated(name, remove=(3, 15))
        return globals()[f"_deprecated_{name}"]
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

A

Is this the standard idiom for deprecating names?

@erlend-aasland
Copy link
Contributor

Is this the standard idiom for deprecating names?

That pattern (and variations over it) is used several places in Lib/, so I guess you can call it a standard idiom.

csv.py - read/write/investigate CSV files
This module provides classes that assist in the reading and writing
of Comma Separated Value (CSV) files, and implements the interface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
of Comma Separated Value (CSV) files, and implements the interface
of comma-separated values files, and implements the interface

@smontanaro
Copy link
Contributor Author

smontanaro commented Jan 18, 2024 via email

@merwok
Copy link
Member

merwok commented Jan 18, 2024

I am not sure that there’s enough demand for it, nor a natural place.
It’s too specific to the Python stdlib to be in warnings, and I don’t think there’s any module concerned with meta-stdlib utilities.

@AA-Turner AA-Turner enabled auto-merge (squash) January 18, 2024 19:22
@AA-Turner AA-Turner merged commit 72abb8c into python:main Jan 18, 2024
@miss-islington-app
Copy link

Thanks @smontanaro for the PR, and @AA-Turner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @smontanaro and @AA-Turner, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 72abb8c5d487ead9eb115fec8132ccef5ba189e5 3.12

@miss-islington-app
Copy link

Sorry, @smontanaro and @AA-Turner, I could not cleanly backport this to 3.11 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 72abb8c5d487ead9eb115fec8132ccef5ba189e5 3.11

@smontanaro
Copy link
Contributor Author

I don't think this change should be backported. How did the attempt happen?

@AA-Turner
Copy link
Member

I added the backport labels after my note above:

Thoughts on backports? I'm somewhat tempted, as future changes to the CSV docstring will be much harder if this PR isn't backported

Though given the backport would require manual work regardless, I agree on leaving it for now & not backporting.

A

@smontanaro
Copy link
Contributor Author

Hmmm... Okay, go for it. Let the chips fall where they may.

@merwok
Copy link
Member

merwok commented Jan 18, 2024

Even if this is all about internal location of attributes, it feels safer to not backport.
Not worth any risk, and possible docstring backports will have to be done by hand.

@AA-Turner AA-Turner removed needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Jan 18, 2024
@smontanaro smontanaro deleted the issue114123 branch January 19, 2024 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants