Skip to content

replacing .format with f-strings #31628

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

Merged
merged 3 commits into from
Feb 3, 2020

Conversation

drewseibert
Copy link
Contributor

@drewseibert drewseibert commented Feb 3, 2020

fixing some styling (using f-strings instead of .format)

@@ -61,7 +61,7 @@ def compare_element(result, expected, typ, version=None):
assert result.freq == expected.freq
else:
comparator = getattr(
tm, "assert_{typ}_equal".format(typ=typ), tm.assert_almost_equal
tm, f"assert_{typ=typ}_equal", tm.assert_almost_equal
Copy link
Member

Choose a reason for hiding this comment

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

Thanks @drewseibert

Did you try running this test to see if it works?

pytest  pandas/tests/io/test_pickle.py

(for more on testing, see Test-driven development/code writing)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MarcoGorelli Hi Marco, thanks for taking a look. Just gave it a run locally and I see this:

Traceback (most recent call last):
File "test_pickle.py", line 25, in
from pandas.compat import _get_lzma_file, _import_lzma, is_platform_little_endian
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/init.py", line 188, in
v = get_versions()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pandas/_version.py", line 23, in get_versions
return json.loads(version_json)
AttributeError: module 'json' has no attribute 'loads'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see any errors related to the f-strings though..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, just ran pytest and got this instead...

../../init.py:36: in
f"C extension: {module} not built. If you want to import "
E ImportError: C extension: No module named 'pandas._libs.tslibs.conversion' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force'
to build the C extensions first.

Copy link
Member

Choose a reason for hiding this comment

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

For C extensions, see creating a development environment

Also, you need to run black against any Python file you've modified, see contributing to the code base

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MarcoGorelli Thanks! Will check those out 👍

@alimcmaster1 alimcmaster1 added Clean Code Style Code style, linting, code_checks labels Feb 3, 2020
@jbrockmendel jbrockmendel merged commit 9853d0e into pandas-dev:master Feb 3, 2020
@jbrockmendel
Copy link
Member

thanks @drewseibert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Code Style Code style, linting, code_checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants