Skip to content

Fix pylint 2.11 consider-using-f-string checker errors - #1517

Merged
weiji14 merged 7 commits into
mainfrom
pylint-2.11
Sep 17, 2021
Merged

Fix pylint 2.11 consider-using-f-string checker errors#1517
weiji14 merged 7 commits into
mainfrom
pylint-2.11

Conversation

@weiji14

@weiji14 weiji14 commented Sep 17, 2021

Copy link
Copy Markdown
Member

Description of proposed changes

Pylint v2.11.1 released on 17 Sep 2021 added a few more checks, most notably, a recommendation to use f-strings (C0209), and a couple of other ones.

pylint pygmt setup.py doc/conf.py
************* Module pygmt.figure
pygmt/figure.py:106:38: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/figure.py:361:24: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/figure.py:363:24: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
************* Module pygmt.src.grd2cpt
pygmt/src/grd2cpt.py:170:24: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary)
************* Module pygmt.src.legend
pygmt/src/legend.py:89:34: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
************* Module pygmt.src.makecpt
pygmt/src/makecpt.py:154:20: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary)
************* Module pygmt.src.surface
pygmt/src/surface.py:108:38: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
************* Module pygmt.src.x2sys_cross
pygmt/src/x2sys_cross.py:204:20: W1514: Using open without explicitly specifying an encoding (unspecified-encoding)
************* Module pygmt.src.config
pygmt/src/config.py:59:13: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/src/config.py:70:13: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
************* Module pygmt
pygmt/__init__.py:80:25: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/__init__.py:215:20: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
************* Module pygmt.src.meca
pygmt/src/meca.py:458:34: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
************* Module pygmt.clib.session
pygmt/clib/session.py:192:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/clib/session.py:369:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/clib/session.py:415:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/clib/session.py:465:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/clib/session.py:506:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/clib/session.py:653:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/clib/session.py:660:18: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/clib/session.py:664:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/clib/session.py:674:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/clib/session.py:908:31: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/clib/session.py:977:31: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/clib/session.py:1086:35: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
************* Module pygmt.tests.test_clib
pygmt/tests/test_clib.py:156:36: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:367:44: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:370:17: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:372:23: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:489:44: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:492:17: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:494:23: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:550:44: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:553:17: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:555:23: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:582:44: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:585:17: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:587:23: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:605:44: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:608:17: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:610:23: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:631:44: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:635:20: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:639:23: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:654:40: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:657:13: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:659:19: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:689:34: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/tests/test_clib.py:696:34: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
************* Module conf
doc/conf.py:130:13: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
************* Module pygmt.helpers.testing
pygmt/helpers/testing.py:116:24: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
************* Module pygmt.helpers.decorators
pygmt/helpers/decorators.py:471:27: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pygmt/helpers/decorators.py:693:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)

-----------------------------------
Your code has been rated at 9.90/10

Luckily there was a tool called flynt that semi-automatically did the f-string conversion, so I only had to manually change some that weren't caught. Let me know if you find any more!

Also made some edits where dict.keys() was not required anymore, and a missing encoding from pathlib.Path.read_text()

Fixes #

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

@weiji14 weiji14 added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog labels Sep 17, 2021
@weiji14 weiji14 self-assigned this Sep 17, 2021
@weiji14 weiji14 added this to the 0.5.0 milestone Sep 17, 2021
@weiji14
weiji14 marked this pull request as ready for review September 17, 2021 05:57
@weiji14
weiji14 merged commit 7a7e861 into main Sep 17, 2021
@weiji14
weiji14 deleted the pylint-2.11 branch September 17, 2021 07:40
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
…gTools#1517)

* Use f-strings throughout the project
* Fix C0201 consider-iterating-dictionary
* Fix W1514 unspecified-encoding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants