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

setup.py: Properly add _sdl2_data_files to data_files #2770

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

cclauss
Copy link
Contributor

@cclauss cclauss commented Mar 25, 2024

Currently, this code is ALWAYS adding an empty list instead of the data files that were found by glob.glob().

It adds the empty list before filling the list!

@cclauss cclauss requested a review from a team as a code owner March 25, 2024 17:41
Copy link
Member

@ankith26 ankith26 left a comment

Choose a reason for hiding this comment

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

The current code isn't broken, because of mutability of lists (the same list is being filled, so finally it isn't actually empty)

But thanks for the PR, the code is now less-weird and simpler. 🎉

@cclauss
Copy link
Contributor Author

cclauss commented Mar 25, 2024

TIL:

>>> big = []
>>> little = []
>>> big.append(("little", little))
>>> big
[('little', [])]
>>> for c in "abc":
...     little.append(c)
...
>>> little
['a', 'b', 'c']
>>> big
[('little', ['a', 'b', 'c'])]

Currently, this code is _ALWAYS_ adding an empty list instead of the data files that were found by `glob.glob()`.
Copy link
Member

@oddbookworm oddbookworm left a comment

Choose a reason for hiding this comment

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

Now that we support only python 3.8+, I'd love to see more use of the walrus operator when it makes sense to do so

@oddbookworm oddbookworm added this to the 2.5.0 milestone Mar 27, 2024
@oddbookworm oddbookworm merged commit bd184c3 into pygame-community:main Mar 27, 2024
29 checks passed
@ankith26 ankith26 added Code quality/robustness Code quality and resilience to changes setup.py labels Mar 27, 2024
@cclauss cclauss deleted the patch-1 branch March 27, 2024 08:21
@cclauss
Copy link
Contributor Author

cclauss commented Mar 27, 2024

Once pre-commit is merged, we can add auto-walrus if you would like...

% auto-walrus **/*.py

Rewriting buildconfig/msysio.py
Rewriting src_py/sprite.py
Rewriting src_py/sysfont.py
Rewriting test/controller_test.py
Rewriting test/mask_test.py
Rewriting test/mixer_test.py
Rewriting test/test_utils/test_runner.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code quality/robustness Code quality and resilience to changes setup.py
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants