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

style: Fix multi-value-repeated-key-literal (F601) (Pylint W0109) #4557

Merged
merged 1 commit into from
Oct 20, 2024

Conversation

echoix
Copy link
Member

@echoix echoix commented Oct 20, 2024

Ruff rule: https://docs.astral.sh/ruff/rules/multi-value-repeated-key-literal/
Pylint : https://pylint.readthedocs.io/en/latest/user_guide/messages/warning/duplicate-key.html

Two instances fixed.

Just to prove that a repeated key in a dict is the same as the last one, I tested it out in a simple example, in IPython:
image

gitpod /workspace/grass (main) $ ipython
Python 3.12.6 (main, Sep  9 2024, 10:33:54) [GCC 11.4.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.27.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]:     aa =   {
   ...:                     "pos": "posvalue",
   ...:                     "size": "sizevalue",
   ...:                     "text": "textvalue1",
   ...:                     "id": 42,
   ...:                     "text": "textvalue2",
   ...:                 }

In [2]: aa
Out[2]: {'pos': 'posvalue', 'size': 'sizevalue', 'text': 'textvalue2', 'id': 42}

In [3]: print((
   ...:             "Unable to write history for <%(map)s>. "
   ...:             "Raster map <%(map)s> not found in current mapset."
   ...:         )
   ...:         % {"map": "mapvalue1", "map": "mapvalue2"})
Unable to write history for <mapvalue2>. Raster map <mapvalue2> not found in current mapset.

In [4]: 

@echoix echoix requested a review from ninsbl October 20, 2024 13:54
@echoix echoix enabled auto-merge (squash) October 20, 2024 13:54
@github-actions github-actions bot added GUI wxGUI related Python Related code is in Python libraries labels Oct 20, 2024
@echoix echoix merged commit 884fc6f into OSGeo:main Oct 20, 2024
26 checks passed
@echoix echoix deleted the fix-F601-multi-value-repeated-key-literal branch October 20, 2024 15:13
@github-actions github-actions bot added this to the 8.5.0 milestone Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI wxGUI related libraries Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants