Skip to content

Commit deeafea

Browse files
authored
chore(packaging): Convert project to src-layout (#736)
* 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
1 parent ae5057d commit deeafea

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

hatch.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
[build.targets.sdist]
22
include = [
3-
'hooks/*.py',
4-
]
5-
exclude = [
6-
'hooks/*.sh',
3+
'src/',
74
]
85

96
[build.targets.wheel]
107
packages = [
11-
'hooks/',
8+
'src/pre_commit_terraform/',
129
]
1310

1411
[metadata.hooks.vcs.urls]

hooks/__init__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ file = 'README.md'
3333
content-type = 'text/markdown'
3434

3535
[project.scripts]
36-
terraform_docs_replace = 'hooks.terraform_docs_replace:main'
36+
terraform_docs_replace = 'pre_commit_terraform.terraform_docs_replace:main'

hooks/terraform_docs_replace.py renamed to src/pre_commit_terraform/terraform_docs_replace.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import os
33
import subprocess
44
import sys
5+
import warnings
56

67

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

31+
warnings.warn(
32+
'`terraform_docs_replace` hook is DEPRECATED.'
33+
'For migration instructions see '
34+
'https://github.com/antonbabenko/pre-commit-terraform/issues/248'
35+
'#issuecomment-1290829226',
36+
category=UserWarning,
37+
)
38+
3039
dirs = []
3140
for filename in args.filenames:
3241
if (os.path.realpath(filename) not in dirs and

0 commit comments

Comments
 (0)