| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow these steps to rectify the issue:
Thanks again to your contribution and we look forward to looking at it! |
Sorry, something went wrong.
|
Thanks for working on this. Doc changes are also needed. |
Sorry, something went wrong.
|
As well as tests for the deprecation message. |
Sorry, something went wrong.
|
Somehow I hadn't noticed that 'monetary' wasn't supported by format_string. So that is actually an enhancement, in addition to the deprecation, and needs to be documented as such (versionchanged, whats new entry). Also, format itself shouldn't be changed, just deprecated (that is, the deprecation message code added, but nothing else in it changed). |
Sorry, something went wrong.
|
@bitdancer I don't think to keep locale.format as it is and just displaying deprecated warning would be of any use. I think it is safe to call locale.format_string internally. |
Sorry, something went wrong.
| grouping strings. | ||
| Replaces :meth:`format`. | ||
|
|
||
|
|
There was a problem hiding this comment.
The description of the monetary parameter should be added to the regular docs, and the version changed phrase should just say "the monetary keyword parameter was added"
Sorry, something went wrong.
|
That's the way we normally do deprecations: leave the existing code in place (so its behavior doesn't change) but point people to the preferred solution. It would be acceptable if there were no behavior changes, but the changed tests prove that there are. |
Sorry, something went wrong.
There was a problem hiding this comment.
Thanks. Almost there :)
It would also be good to have an entry for the What's New document for 3.7 for the addition of the monetary parameter to format_string, as well as the deprecation of format. I haven't looked; if the 3.7 what's new hasn't been organized yet, just stick in a placeholder sentence with a reference to the bpo issue number.
Sorry, something went wrong.
| .. versionchanged:: 3.7 | ||
| Added *monetary*, if true the conversion uses monetary thousands separator and | ||
| grouping strings. | ||
| The *monetary* keyword parameter was added. |
There was a problem hiding this comment.
We still need the description of the monetary keyword (presumably copy and pasted from the existing format entry) in the description of the format_string function.
In fact, what we really want to do is copy most of the 'format' description into format_string, since it seems wrong somehow to refer to the docs of a deprecated from from the preferred function.
Sorry, something went wrong.
| self._test_format("%-10.f", 4200, grouping=0, out='4200'.ljust(10)) | ||
|
|
||
| def test_format_deprecation(self): | ||
| with warnings.catch_warnings(record=True) as w: |
There was a problem hiding this comment.
You can use assertWarns here instead.
Sorry, something went wrong.
|
|
||
| .. versionchanged:: 3.7 | ||
| The *monetary* keyword parameter was added. | ||
| Replaces :meth:`format`. |
There was a problem hiding this comment.
I don't think the 'replaces' sentence is needed. The deprecated on format covers that.
Sorry, something went wrong.
Fixed recommended CR changes
There was a problem hiding this comment.
Thanks for sticking with this :)
Sorry, something went wrong.
| locale settings into account. | ||
|
|
||
| .. versionchanged:: 3.7 | ||
| The *monetary* keyword parameter was added. |
There was a problem hiding this comment.
Missing indentation.
Sorry, something went wrong.
| function instead. | ||
|
|
||
| * Deprecated :meth:`format` from :mod:`locale`, use the :meth:`format_string` | ||
| instead. Added another argument *monetary* in :meth:`format_string` of |
There was a problem hiding this comment.
format hasn't been removed, so the deprecation should go in the deprecation section. The feature addition of the monetary keyword should go in the 'improved modules' section.
Sorry, something went wrong.
Codecov Report
@@ Coverage Diff @@
## master #259 +/- ##
==========================================
- Coverage 83.38% 82.38% -1.01%
==========================================
Files 1367 1428 +61
Lines 344897 351221 +6324
==========================================
+ Hits 287596 289342 +1746
- Misses 57301 61879 +4578Continue to review full report at Codecov.
|
Sorry, something went wrong.
| Improved Modules | ||
| ================ | ||
|
|
||
| * Added another argument *monetary* in :meth:`format_string` of :mod:`locale`. |
There was a problem hiding this comment.
There should be a subsection header before this line for the locale module (the modules with enhancements are listed in this section in alphabetical order).
Sorry, something went wrong.
|
@bitdancer is it good to go now? |
Sorry, something went wrong.
|
Yes, I think so. I'd like to do a final overall review before I approve it, though. With any luck I'll do that tonight. |
Sorry, something went wrong.
|
Thanks! :) |
Sorry, something went wrong.
|
Hey, @bitdancer have you reviewed this? |
Sorry, something went wrong.
|
I did...and I feel bad that I have some more changes to suggest, so I was going to make them myself and submit it to the PR, but I haven't actually figured out how to do that yet. |
Sorry, something went wrong.
|
@bitdancer well I think you can suggest me the changes I'll do my best to figure them out. |
Sorry, something went wrong.
| For whole format strings, use :func:`format_string`. | ||
|
|
||
| .. deprecated:: 3.7 | ||
| Use :meth:`format_string` instead |
There was a problem hiding this comment.
So looking at this again, I think what we should do is move 'format' under 'format_string', and change its body to say "works like format_string but only accepts a single format specification. That followed by the deprecation notice will make it a lot less likely anyone will use it :)
Sorry, something went wrong.
| If *monetary* is true, the conversion uses monetary thousands separator and | ||
| grouping strings. | ||
| (Contributed by Garvit in :issue:`10379`.) | ||
|
|
There was a problem hiding this comment.
Small nit: our convention appears to be to put the Contributed by as part of the paragraph when there's only one paragraph. Ends up formatted the same in html, but might as well make the ReST consistent as well.
Sorry, something went wrong.
| """Deprecated, use format_string instead.""" | ||
| warnings.warn( | ||
| "This method will be removed in future versions. " | ||
| "Use 'locale.format_string()' instead.", |
There was a problem hiding this comment.
I think this should read "This method will be removed in a future version of Python."
Sorry, something went wrong.
| """Formats a string in the same way that the % formatting would use, | ||
| but takes the current locale into account. | ||
| Grouping is applied if the third parameter is true.""" | ||
| Grouping is applied if the third parameter is true. |
There was a problem hiding this comment.
As long as we are editing this, I think there should be a blank line after the first sentence, before the 'Grouping' sentence.
Sorry, something went wrong.
| "the 'C' locale.") | ||
|
|
||
| s = format('%%.%if' % digits, abs(val), grouping, monetary=True) | ||
| s = format_string('%%.%if' % digits, abs(val), grouping, monetary=True) |
There was a problem hiding this comment.
Since we know there's only one format string here, I think this should be a call to _format.
Sorry, something went wrong.
| def str(val): | ||
| """Convert float to string, taking the locale into account.""" | ||
| return format("%.12g", val) | ||
| return format_string("%.12g", val) |
There was a problem hiding this comment.
As above, I think this should be _format.
Sorry, something went wrong.
Refactoring Doc, moving format doc below format_string, this is to make sure people have lesser probability of using format in future. Also using _format method inside locale module, since we know there is only one format function that is _format
|
There was no need to move format in the source file, but it doesn't hurt, either. |
Sorry, something went wrong.
|
Hey @bitdancer is there anything left to get this merged? |
Sorry, something went wrong.
|
Just adding the Misc/NEWS entry. I'm not sure what status is on how to do that currently, but I think it is still manual edit of that file. I haven't had time yet to learn how to update a PR before merge, so if you add the entry, I'll hit merge :) |
Sorry, something went wrong.
| - bpo-29534: Fixed different behaviour of Decimal.from_float() | ||
| for _decimal and _pydecimal. Thanks Andrew Nester. | ||
|
|
||
| - bpo-10379: Deprecate locale.format in lue of locale.format_string |
There was a problem hiding this comment.
Google says it's spelled 'lieu'. Also the entry should note that the monetary argument was added to format_string. So, how about "locale.format_string now supports the 'monetary' keyword argument, and locale.format is deprecated."
Sorry, something went wrong.
Update the Stackless patches for readthedocs.org based on the documentation. This simplified configuration is still untested.
Well, the previous commit didn't build on readthedocs.org. - Rename .readthedocs.yml to .readthedocs.yaml See https://docs.readthedocs.io/en/stable/config-file/index.html - Add a requirements file Doc/slp_readthedocs_requirements.txt and require the same packages as specified in Makefile. Already set the Sphinx version to 2.0.1, because upstream commit 7d23dbe
Set the css-file to "pydoctheme.css".
Remove the explicit specification of the css-file for readthedocs.org. It is not needed any more.
| Back | FazBrowse Home | New Git URL |
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.