Skip to content

Conversation

@C0rn3j
Copy link
Contributor

@C0rn3j C0rn3j commented Jul 23, 2025

Convert __init__.py to use dynamic indents to allow setting preferred indent-width.

Remove unnecessary decorators, f-strings.

Remove unnecessary importlib import (I don't see it used anywhere) and annotate the ones that are sneakily re-used in other files.

SDL_DOWNLOAD_BINARIES can return None, annotate it as such.

Touchup .gitignore for build module directories.

Remove one instance of an SDL star import in __init__.py - hopefully this is done correctly.

Add LSP/linter definitions to allow them being used properly.

@C0rn3j
Copy link
Contributor Author

C0rn3j commented Jul 23, 2025

@Aermoss What's the point on importing the core libraries through a file import?

from .__init__ import sys, array

It's confusing for linters/type checkers and I do not believe you get any benefit from it, since .pyc caches module imports?

https://docs.python.org/3/faq/programming.html#how-do-i-create-a-pyc-file

@Aermoss
Copy link
Owner

Aermoss commented Jul 23, 2025

@Aermoss What's the point on importing the core libraries through a file import?

from .__init__ import sys, array

It's confusing for linters/type checkers and I do not believe you get any benefit from it, since .pyc caches module imports?

https://docs.python.org/3/faq/programming.html#how-do-i-create-a-pyc-file

It ensures that __init__.py is executed before any other file, even when a file within the module is imported directly.

@Aermoss
Copy link
Owner

Aermoss commented Jul 23, 2025

It looks like it needs a few small adjustments but I'll merge it anyway, thanks a lot for the pull request!

@Aermoss Aermoss closed this Jul 23, 2025
@C0rn3j
Copy link
Contributor Author

C0rn3j commented Jul 23, 2025

Wouldn't that be better achieved by directly checking if it is loaded, and loading it if necessary?

if "sdl3.__init__" not in sys.modules:
  # Load __init__

The way it is done now makes it impossible to get rid of the star imports, as not doing a star import will result in doing circular imports.

@Aermoss Aermoss reopened this Jul 23, 2025
@Aermoss Aermoss marked this pull request as ready for review July 23, 2025 14:10
@Aermoss Aermoss merged commit 2545bb5 into Aermoss:main Jul 23, 2025
0 of 20 checks passed
@C0rn3j C0rn3j deleted the touchups branch July 23, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants