afterpython 0.1.0.dev14__py3-none-any.whl → 0.1.0.dev15__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,38 +7,13 @@ import afterpython as ap
7
7
 
8
8
 
9
9
  def init_ruff_toml():
10
- from afterpython.tools.pre_commit import update_pre_commit
11
-
12
- afterpython_path = ap.paths.afterpython_path
13
- ruff_toml_path = afterpython_path / "ruff.toml"
10
+ ruff_toml_path = ap.paths.afterpython_path / "ruff.toml"
14
11
  if ruff_toml_path.exists():
15
12
  click.echo(f"Ruff configuration file {ruff_toml_path} already exists")
16
13
  return
17
14
  ruff_template_path = ap.paths.templates_path / "ruff-template.toml"
18
15
  shutil.copy(ruff_template_path, ruff_toml_path)
19
16
  click.echo(f"Created {ruff_toml_path}")
20
- # add ruff-pre-commit hook to .pre-commit-config.yaml
21
- data_update = {
22
- "repos": [
23
- {
24
- "repo": "https://github.com/astral-sh/ruff-pre-commit",
25
- "rev": "v0.14.6",
26
- "hooks": [
27
- {
28
- "id": "ruff-check",
29
- "stages": ["pre-commit"],
30
- "args": ["--config", "./afterpython/ruff.toml"],
31
- },
32
- {
33
- "id": "ruff-format",
34
- "stages": ["pre-commit"],
35
- "args": ["--config", "./afterpython/ruff.toml"],
36
- },
37
- ],
38
- },
39
- ]
40
- }
41
- update_pre_commit(data_update)
42
17
 
43
18
 
44
19
  def init_website():
@@ -46,6 +21,24 @@ def init_website():
46
21
  subprocess.run(["ap", "update", "website"])
47
22
 
48
23
 
24
+ def init_py_typed():
25
+ from afterpython.tools.pyproject import find_package_directory
26
+
27
+ try:
28
+ package_dir = find_package_directory()
29
+ except FileNotFoundError:
30
+ click.echo(
31
+ "Could not find package directory (__init__.py not found), skipping py-typed initialization"
32
+ )
33
+ return
34
+ py_typed_path = package_dir / "py.typed"
35
+ if py_typed_path.exists():
36
+ click.echo(f"py.typed file already exists at {py_typed_path}")
37
+ return
38
+ py_typed_path.touch()
39
+ click.echo(f"Created {py_typed_path}")
40
+
41
+
49
42
  @click.command()
50
43
  @click.option(
51
44
  "--yes",
@@ -85,6 +78,9 @@ def init(ctx, yes):
85
78
 
86
79
  init_website()
87
80
 
81
+ # TODO: add type checking related stuff here
82
+ init_py_typed()
83
+
88
84
  create_workflow("deploy")
89
85
  create_workflow("ci")
90
86
 
@@ -0,0 +1,8 @@
1
+ [tool.commitizen]
2
+ name = "cz_conventional_commits"
3
+ # name = "cz_customize"
4
+ tag_format = "v$version"
5
+ version_scheme = "pep440"
6
+ version_provider = "uv"
7
+ update_changelog_on_bump = false
8
+ major_version_zero = true
@@ -0,0 +1,48 @@
1
+ default_install_hook_types:
2
+ - pre-commit
3
+ - commit-msg
4
+ - pre-push
5
+ exclude: ^afterpython/_website/
6
+ repos:
7
+ - repo: https://github.com/pre-commit/pre-commit-hooks
8
+ rev: v6.0.0
9
+ hooks:
10
+ - id: trailing-whitespace
11
+ stages:
12
+ - pre-commit
13
+ - id: end-of-file-fixer
14
+ stages:
15
+ - pre-commit
16
+ - id: check-yaml
17
+ stages:
18
+ - pre-commit
19
+ - id: check-toml
20
+ stages:
21
+ - pre-commit
22
+ - id: check-added-large-files
23
+ stages:
24
+ - pre-commit
25
+ - repo: https://github.com/astral-sh/ruff-pre-commit
26
+ rev: v0.14.6
27
+ hooks:
28
+ - id: ruff-check
29
+ stages:
30
+ - pre-commit
31
+ args:
32
+ - --config
33
+ - ./afterpython/ruff.toml
34
+ - id: ruff-format
35
+ stages:
36
+ - pre-commit
37
+ args:
38
+ - --config
39
+ - ./afterpython/ruff.toml
40
+ - repo: https://github.com/commitizen-tools/commitizen
41
+ rev: v4.10.0
42
+ hooks:
43
+ - id: commitizen
44
+ stages:
45
+ - commit-msg
46
+ - id: commitizen-branch
47
+ stages:
48
+ - pre-push
@@ -1,52 +1,13 @@
1
- import afterpython as ap
2
-
3
- commitizen_default = {
4
- "tool": {
5
- "commitizen": {
6
- "name": "cz_conventional_commits",
7
- "tag_format": "v$version",
8
- "version_scheme": "pep440",
9
- "version_provider": "uv",
10
- "update_changelog_on_bump": False,
11
- "major_version_zero": True,
12
- }
13
- }
14
- }
1
+ import shutil
15
2
 
16
-
17
- commitizen_pre_commit_hook = {
18
- "repos": [
19
- {
20
- "repo": "https://github.com/commitizen-tools/commitizen",
21
- "rev": "v4.10.0",
22
- "hooks": [
23
- {
24
- "id": "commitizen",
25
- "stages": ["commit-msg"],
26
- },
27
- {
28
- "id": "commitizen-branch",
29
- "stages": ["pre-push"],
30
- },
31
- ],
32
- },
33
- ]
34
- }
3
+ import afterpython as ap
35
4
 
36
5
 
37
6
  def init_commitizen():
38
- from afterpython._io.toml import write_toml
39
- from afterpython.tools.pre_commit import update_pre_commit
40
-
41
- afterpython_path = ap.paths.afterpython_path
42
- commitizen_toml_path = afterpython_path / "cz.toml"
7
+ commitizen_toml_path = ap.paths.afterpython_path / "cz.toml"
43
8
  if commitizen_toml_path.exists():
44
9
  print(f"Commitizen configuration file {commitizen_toml_path} already exists")
45
10
  return
46
-
47
- # Create commitizen configuration with default values
48
- write_toml(commitizen_toml_path, commitizen_default)
11
+ cz_template_path = ap.paths.templates_path / "cz-template.toml"
12
+ shutil.copy(cz_template_path, commitizen_toml_path)
49
13
  print(f"Created {commitizen_toml_path}")
50
-
51
- # add commitizen hook to .pre-commit-config.yaml
52
- update_pre_commit(commitizen_pre_commit_hook)
@@ -1,35 +1,9 @@
1
+ import shutil
1
2
  import subprocess
2
3
 
3
4
  import afterpython as ap
4
5
  from afterpython._io.yaml import read_yaml, write_yaml
5
6
 
6
- pre_commit_default = {
7
- # default is only ["pre-commit"], without changing the default,
8
- # we need to explicitly pass in --hook-type whenever we run "pre-commit install --hook-type ..."
9
- "default_install_hook_types": ["pre-commit", "commit-msg", "pre-push"],
10
- "exclude": "^afterpython/_website/", # do not check the project website template
11
- "repos": [
12
- {
13
- "repo": "https://github.com/pre-commit/pre-commit-hooks",
14
- "rev": "v6.0.0",
15
- "hooks": [
16
- {"id": "trailing-whitespace", "stages": ["pre-commit"]},
17
- {"id": "end-of-file-fixer", "stages": ["pre-commit"]},
18
- {"id": "check-yaml", "stages": ["pre-commit"]},
19
- {"id": "check-toml", "stages": ["pre-commit"]},
20
- {"id": "check-added-large-files", "stages": ["pre-commit"]},
21
- ],
22
- },
23
- # {
24
- # "repo": "https://github.com/astral-sh/uv-pre-commit",
25
- # "rev": "0.9.8",
26
- # "hooks": [
27
- # {"id": "uv-lock"}, # Update the uv lockfile
28
- # ]
29
- # },
30
- ],
31
- }
32
-
33
7
 
34
8
  def install_pre_commit():
35
9
  # installed in .git/hooks
@@ -55,6 +29,9 @@ def init_pre_commit():
55
29
  if pre_commit_path.exists():
56
30
  print(f".pre-commit-config.yaml already exists at {pre_commit_path}")
57
31
  return
58
- write_yaml(pre_commit_path, pre_commit_default)
32
+ pre_commit_template_path = (
33
+ ap.paths.templates_path / "pre-commit-config-template.yaml"
34
+ )
35
+ shutil.copy(pre_commit_template_path, pre_commit_path)
59
36
  print(f"Created {pre_commit_path}")
60
37
  install_pre_commit()
@@ -6,6 +6,7 @@ if TYPE_CHECKING:
6
6
  from tomlkit.toml_document import TOMLDocument
7
7
 
8
8
  import asyncio
9
+ from pathlib import Path
9
10
 
10
11
  from pyproject_metadata import StandardMetadata
11
12
 
@@ -27,6 +28,41 @@ def read_metadata() -> StandardMetadata:
27
28
  return StandardMetadata.from_pyproject(read_pyproject())
28
29
 
29
30
 
31
+ def find_package_directory() -> Path:
32
+ """Find the user's package directory.
33
+
34
+ Supports both common Python project layouts:
35
+ - src layout: user_project/src/package_name/__init__.py
36
+ - flat layout: user_project/package_name/__init__.py
37
+
38
+ Returns:
39
+ Path to the package directory containing __init__.py
40
+
41
+ Raises:
42
+ FileNotFoundError: If package directory cannot be found in either layout
43
+ """
44
+ metadata = read_metadata()
45
+ package_name = metadata.name
46
+ project_root = ap.paths.user_path
47
+
48
+ # Try src layout first (recommended layout)
49
+ src_layout_dir = project_root / "src" / package_name
50
+ if (src_layout_dir / "__init__.py").exists():
51
+ return src_layout_dir
52
+
53
+ # Try flat layout
54
+ flat_layout_dir = project_root / package_name
55
+ if (flat_layout_dir / "__init__.py").exists():
56
+ return flat_layout_dir
57
+
58
+ # Package not found in either location
59
+ raise FileNotFoundError(
60
+ f"Could not find package '{package_name}' in either src layout "
61
+ f"({src_layout_dir}) or flat layout ({flat_layout_dir}). "
62
+ f"Expected to find __init__.py in one of these locations."
63
+ )
64
+
65
+
30
66
  def init_pyproject():
31
67
  """Initialize pyproject.toml with sensible defaults
32
68
  - add [build-system] section with uv build backend (same as `uv init --package`)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: afterpython
3
- Version: 0.1.0.dev14
3
+ Version: 0.1.0.dev15
4
4
  Summary: CLI tool to streamline Python package maintenance and generate a dedicated project website
5
5
  Keywords: package-maintenance,project-website,static-site-generator,developer-tools,documentation,cli-tool,ci/cd,mystmd,semantic-release,python-packaging
6
6
  Author: Stephen Yau
@@ -16,7 +16,7 @@ afterpython/cli/commands/commit.py,sha256=TKhlybJxbcChMzZJuTfYafCrYUraqyBpLJ4TP0
16
16
  afterpython/cli/commands/commitizen.py,sha256=naI8j4pfXIMsiOLmPMeZTGh831I3665_1_Sbn7yoKyE,811
17
17
  afterpython/cli/commands/dev.py,sha256=zuto7Z6nfD1FAhZkhZNoLhxVH78Eo3W3iO6QujOMXII,6753
18
18
  afterpython/cli/commands/format.py,sha256=cXvuc-6XwULM1VJjS2B2bJBvnV1TVHFl1CeSs0SYQ24,738
19
- afterpython/cli/commands/init.py,sha256=lyNcE-fmgXyLGoSRkvHg_xpDt9gnySemTh-0m6lX0Ws,3354
19
+ afterpython/cli/commands/init.py,sha256=TW8uIl_pt0HH9QCQLgFkJhM86VF_vwP1Wlqq0fXR8VI,3124
20
20
  afterpython/cli/commands/init_branch_rules.py,sha256=fzAm8D5qbW3u4bEMpqPuRgO-0akuCGG7pu09JlKhYn4,243
21
21
  afterpython/cli/commands/install.py,sha256=K3xYzU7XOts_xdERyd4q3wUFv0hythy7ZP6jr9N_6L4,777
22
22
  afterpython/cli/commands/lock.py,sha256=WAfZY4Jb7XLl7_zcjxCAs8VCGitX-zPlkXLTkPtOqDs,605
@@ -32,21 +32,23 @@ afterpython/const.py,sha256=B_yUBmHPyu98aOibwt7idWbhKNBBed0TeYXNBd8tPTk,157
32
32
  afterpython/main.py,sha256=w0z6mTib3u4p2HxMrk-tIJlZtur7uRaqsbE0ewlYlSs,490
33
33
  afterpython/pcu.py,sha256=EoEhSzFZ49b5qc9KH2RLxIHSzY8YFM5uhtw07chcrr8,6093
34
34
  afterpython/templates/ci-workflow-template.yml,sha256=2L-SRPB2GKlfR4bQAgpdq4r9bFdT9vCYo4oWjnIzKfg,5933
35
+ afterpython/templates/cz-template.toml,sha256=AS7ZaPhfgbPEwUdHW6pAJueC3ZXneABkfPg2SQdznmU,209
35
36
  afterpython/templates/dependabot-template.yml,sha256=CBQEgh8EsXw2X7IqzGtFI7lVT9liF6PW4DvGLB0X2LY,1136
36
37
  afterpython/templates/deploy-workflow-template.yml,sha256=2W4K3lKMYjSTPrlXIsMweBzqP9IoLtZXAAcUu5FA5NA,2365
38
+ afterpython/templates/pre-commit-config-template.yaml,sha256=Dv2BnTxgdzwKC9_QXkWkpRys8zN1tdqZ3ApQ1Zjl1ww,915
37
39
  afterpython/templates/release-workflow-template.yml,sha256=3YBkgrqmi--uznslpMxPz7Vj7L4_NPlhDxgwYBt-Ui8,1606
38
40
  afterpython/templates/ruff-template.toml,sha256=lNCd4EthoLScr4cyVEgGUH4xK5CfIX3f9I3zkJHAYgg,1008
39
41
  afterpython/tools/_afterpython.py,sha256=aZdRJ9dprA1HFchDFTqreJbrsI_HTPUaxtuBinVz10I,1905
40
42
  afterpython/tools/_git.py,sha256=aO-qDEQ4OevD_B74DYKK4nQKYeiaS1BXmYc8paJRfbQ,3772
41
43
  afterpython/tools/branch_rules.py,sha256=ciQ2H2YBnoCZu_plyVeIHzf2FcAILRFhpjzOR2_IfJg,3159
42
- afterpython/tools/commitizen.py,sha256=xpLZJuEqrRxCYz8la6po1PIlECk9O1BuAgsmSE1EY3I,1468
44
+ afterpython/tools/commitizen.py,sha256=ZO1qHmzUU0myd85tncv76WtIR7DB_AoQGSUvaf78Ohg,438
43
45
  afterpython/tools/github_actions.py,sha256=zVmg9aqUg-EO0CnbRHl9i8TmFtXpt7nd0VjzckqqE30,1527
44
46
  afterpython/tools/myst.py,sha256=fh0FtgL9A1dmFa98QKsWFqExsG7hPRP3nrj62U9PmaA,6603
45
- afterpython/tools/pre_commit.py,sha256=U4cazFxaZmyamk_n-85sL6BLOttURm-I2giksgE0qb8,2191
46
- afterpython/tools/pyproject.py,sha256=YiSbW-bXYtFCkXRl_Ibdca2OeYZT0lsqzRRjZFxMcp4,2327
47
+ afterpython/tools/pre_commit.py,sha256=oNsrUkPI13rSSBSyhyTTKPnQGhDxLIPYhxu6kL0fDmo,1206
48
+ afterpython/tools/pyproject.py,sha256=kb7BDn24yH_xS2F5_L0dK-GL4KgOJS-MIIUQhHnLorI,3507
47
49
  afterpython/utils.py,sha256=Uh4pTGeavH5pf8GCeMYQGqs3iPpZzjjAJ_R7t2mhEyY,7045
48
50
  afterpython/version.py,sha256=hihRV1S-gc1m46OaXD32ikkEkqzs-Gtq7AcAqOQV-wY,1603
49
- afterpython-0.1.0.dev14.dist-info/WHEEL,sha256=3id4o64OvRm9dUknh3mMJNcfoTRK08ua5cU6DFyVy-4,79
50
- afterpython-0.1.0.dev14.dist-info/entry_points.txt,sha256=roa0PDgBueM1JPbRG0G2OSxzaN394OUL_oS9iEwVLBc,80
51
- afterpython-0.1.0.dev14.dist-info/METADATA,sha256=0w7h6S6kh0OKV_LMX2BEOV89VnPTJ-AP-U-w1llWp_0,5907
52
- afterpython-0.1.0.dev14.dist-info/RECORD,,
51
+ afterpython-0.1.0.dev15.dist-info/WHEEL,sha256=3id4o64OvRm9dUknh3mMJNcfoTRK08ua5cU6DFyVy-4,79
52
+ afterpython-0.1.0.dev15.dist-info/entry_points.txt,sha256=roa0PDgBueM1JPbRG0G2OSxzaN394OUL_oS9iEwVLBc,80
53
+ afterpython-0.1.0.dev15.dist-info/METADATA,sha256=xcVL1wJJ5Tk0F2UvwCHzvZKU7uXoQKddOcdF9HdURH4,5907
54
+ afterpython-0.1.0.dev15.dist-info/RECORD,,