Skip to content

Commit

Permalink
chore(packaging): Convert project to src-layout (#736)
Browse files Browse the repository at this point in the history
* Drop top import package deprecation warning

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.

* 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]].

[1]: https://blog.ganssle.io/articles/2019/08/test-as-installed.html
  • Loading branch information
webknjaz authored Dec 28, 2024
1 parent ae5057d commit deeafea
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
7 changes: 2 additions & 5 deletions hatch.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
[build.targets.sdist]
include = [
'hooks/*.py',
]
exclude = [
'hooks/*.sh',
'src/',
]

[build.targets.wheel]
packages = [
'hooks/',
'src/pre_commit_terraform/',
]

[metadata.hooks.vcs.urls]
Expand Down
4 changes: 0 additions & 4 deletions hooks/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ file = 'README.md'
content-type = 'text/markdown'

[project.scripts]
terraform_docs_replace = 'hooks.terraform_docs_replace:main'
terraform_docs_replace = 'pre_commit_terraform.terraform_docs_replace:main'
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import subprocess
import sys
import warnings


def main(argv=None):
Expand All @@ -27,6 +28,14 @@ def main(argv=None):
parser.add_argument('filenames', nargs='*', help='Filenames to check.')
args = parser.parse_args(argv)

warnings.warn(
'`terraform_docs_replace` hook is DEPRECATED.'
'For migration instructions see '
'https://github.com/antonbabenko/pre-commit-terraform/issues/248'
'#issuecomment-1290829226',
category=UserWarning,
)

dirs = []
for filename in args.filenames:
if (os.path.realpath(filename) not in dirs and
Expand Down

0 comments on commit deeafea

Please sign in to comment.