Skip to content

chore(packaging): Convert project to src-layout#736

Merged
MaxymVlasov merged 2 commits intoantonbabenko:masterfrom
webknjaz:maintenance/src-layout
Dec 28, 2024
Merged

chore(packaging): Convert project to src-layout#736
MaxymVlasov merged 2 commits intoantonbabenko:masterfrom
webknjaz:maintenance/src-layout

Conversation

@webknjaz
Copy link
Contributor

📦 Convert project to src-layout

This is one of the most resilient Python project structures that
offers isolation and prevents accidental local imports during testing
[1].

The change also includes moving the deprecation message into a warning
raised from the affected script in runtime as opposed to import time.
In general, it's harmful to have such logic in __init__.py since
it's executed at import time and would get triggered when interacting
with other importables from the same namespace just as well.

Put an x into the box if that apply:

  • This PR introduces breaking change.
  • This PR fixes a bug.
  • This PR adds new functionality.
  • This PR enhances existing functionality.

Description of your changes

$sbj.

How can we test changes

python -Im build

webknjaz and others added 2 commits December 28, 2024 05:27
This patch puts it directly into the check script.

In general, it's harmful to have such logic in `__init__.py` since
it's executed at import time and would get triggered when interacting
with other importables from the same namespace just as well.
This is one of the most resilient Python project structures that
offers isolation and prevents accidental local imports during testing
[[1]].

[1]: https://blog.ganssle.io/articles/2019/08/test-as-installed.html
@MaxymVlasov MaxymVlasov changed the title chore(packaging): X📦 Convert project to src-layout chore(packaging): Convert project to src-layout Dec 28, 2024
Comment on lines +33 to +35
'For migration instructions see '
'https://github.com/antonbabenko/pre-commit-terraform/issues/248'
'#issuecomment-1290829226',
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is a linter in my branch, which ask to avoid implicit string concatenations, so, let's not make it less happy (no matter that this hook is not supported anymore)

Suggested change
'For migration instructions see '
'https://github.com/antonbabenko/pre-commit-terraform/issues/248'
'#issuecomment-1290829226',
'For migration instructions see '
+ 'https://github.com/antonbabenko/pre-commit-terraform/issues/248'
+ '#issuecomment-1290829226',

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You missed one line in the code suggestion. Also, we talked about disabling that rule, so I suggest skipping this change. Besides, this isn't exactly in the scope of the PR as the implicit concatenation was used in __init__.py and I didn't change that.

Copy link
Collaborator

@MaxymVlasov MaxymVlasov Dec 28, 2024

Choose a reason for hiding this comment

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

Yep, I run test and explitit concatenation is =< 1 * 10^-8 seconds more time consuming than implicit
I don't think that it's a big deal in our case, but i'm good to merge it now as is

Copy link
Collaborator

Choose a reason for hiding this comment

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

is =< 1 * 10^-8 seconds more time consuming
I don't think that it's a big deal in our case, but i'm good to merge it now as is

Jeez, dude, you're throwing nanoseconds around like a drunken sailor 🤣

Copy link
Collaborator

@MaxymVlasov MaxymVlasov left a comment

Choose a reason for hiding this comment

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

I surprised that this time __init__.py can be finally removed and not causes any issues 🎉

@MaxymVlasov MaxymVlasov merged commit deeafea into antonbabenko:master Dec 28, 2024
6 checks passed
@antonbabenko
Copy link
Owner

This PR is included in version 1.97.0 🎉

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.

4 participants