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

wxGUI/datacatalog: Replace lambda expression with named Function to fix E731 #4377

Merged
merged 3 commits into from
Sep 25, 2024

Conversation

arohanajit
Copy link
Contributor

Description

This PR addresses the E731 linting issue in tree.py by replacing a lambda expression with a named function. The change ensures that the code adheres to PEP 8 guidelines, which recommend using a def statement instead of assigning a lambda expression.

Changes Made

  • Defined a new function _callback to replace the lambda expression.
  • Updated the code to use the _callback function.

Rationale

  • Just recreated lambda function with a normal def function as specified in the flake8

@github-actions github-actions bot added GUI wxGUI related Python Related code is in Python labels Sep 24, 2024
@echoix
Copy link
Member

echoix commented Sep 24, 2024

To review carefully. Last time I touched lambdas and gui, we ended up needing to revert.

Copy link
Contributor

@petrasovaa petrasovaa 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 this should work, a simple example:

>>> x = 1
>>> def test(x=x):
...     print(x)
... 
>>> test()
1
>>> x = 2
>>> test()
1

Just renaming the function (see the comment) seemed unnecessary, no?

gui/wxpython/datacatalog/tree.py Outdated Show resolved Hide resolved
Co-authored-by: Anna Petrasova <kratochanna@gmail.com>
Copy link
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

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

Looks like removing E402 is unrelated, but as long as the checks pass, that's fine I guess, probably some leftover.

@petrasovaa petrasovaa changed the title tools: wxPython/datacatalog: Replace Lambda Expression with Named Function to Fix E731 GUI/datacatalog: Replace lambda expression with named Function to fix E731 Sep 24, 2024
@petrasovaa petrasovaa added this to the 8.5.0 milestone Sep 24, 2024
@arohanajit arohanajit changed the title GUI/datacatalog: Replace lambda expression with named Function to fix E731 wxGUI/datacatalog: Replace lambda expression with named Function to fix E731 Sep 24, 2024
@petrasovaa petrasovaa merged commit 7c651c3 into OSGeo:main Sep 25, 2024
27 of 28 checks passed
@arohanajit arohanajit deleted the flake8-datacatalog branch September 26, 2024 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI wxGUI related Python Related code is in Python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants