crackerjack 0.7.4__tar.gz → 0.7.6__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Crackerjack
3
- Version: 0.7.4
3
+ Version: 0.7.6
4
4
  Summary: Crackerjack code style
5
5
  Keywords: black ruff mypy creosote refurb
6
6
  Home-page: https://github.com/lesleslie/crackerjack
@@ -32,7 +32,7 @@ Requires-Dist: pre-commit>=3.4.0
32
32
  Requires-Dist: pytest>=7.4.2
33
33
  Requires-Dist: pydantic>=2.4.0
34
34
  Requires-Dist: aiopath>=0.7.5
35
- Requires-Dist: acb>=0.3.3
35
+ Requires-Dist: acb>=0.3.4
36
36
  Description-Content-Type: text/markdown
37
37
 
38
38
  # Crackerjack Python
@@ -0,0 +1,6 @@
1
+ python_version: "3.12"
2
+ pre_commit_path: "/usr/local/bin/pre-commit"
3
+ git_path: "/usr/bin/git"
4
+ pdm_path: "/Users/les/.local/bin/pdm"
5
+ zshenv_path: "/Users/les/.zenv"
6
+
@@ -11,3 +11,4 @@
11
11
  /tmp/
12
12
  /__pycache__/
13
13
  /*.pyc
14
+ /.crackerjack.yaml
@@ -7,7 +7,6 @@ from subprocess import run
7
7
 
8
8
  from acb.actions.encode import dump
9
9
  from acb.actions.encode import load
10
-
11
10
  from aioconsole import ainput
12
11
  from aioconsole import aprint
13
12
  from aiopath import AsyncPath
@@ -15,25 +14,25 @@ from inflection import underscore
15
14
  from pydantic import BaseModel
16
15
 
17
16
 
18
- class Commands(BaseModel):
19
- pre_commit: str = "/usr/local/bin/pre-commit"
20
- git: str = "/usr/bin/git"
21
- pdm: str = "/usr/local/bin/pdm"
22
-
23
-
24
- commands = Commands()
17
+ class Config(BaseModel):
18
+ python_version: t.Optional[str] = None
19
+ pre_commit_path: t.Optional[Path] = None
20
+ git_path: t.Optional[Path] = None
21
+ pdm_path: t.Optional[Path] = None
22
+ zshenv_path: t.Optional[Path] = None
25
23
 
26
24
 
27
25
  class Crakerjack(BaseModel, arbitrary_types_allowed=True):
28
26
  our_path: AsyncPath = AsyncPath(__file__).parent
29
27
  pkg_path: AsyncPath = AsyncPath(Path.cwd())
28
+ settings_path: AsyncPath = pkg_path / ".crackerjack.yaml"
30
29
  pkg_dir: t.Optional[AsyncPath] = None
31
30
  pkg_name: str = "crackerjack"
32
31
  our_toml: t.Optional[dict[str, t.Any]] = None
33
32
  pkg_toml: t.Optional[dict[str, t.Any]] = None
34
33
  our_toml_path: t.Optional[AsyncPath] = None
35
34
  pkg_toml_path: t.Optional[AsyncPath] = None
36
- poetry_pip_env: bool = False
35
+ config: t.Optional[Config] = None
37
36
 
38
37
  async def update_pyproject_configs(self) -> None:
39
38
  toml_file = "pyproject.toml"
@@ -67,11 +66,10 @@ class Crakerjack(BaseModel, arbitrary_types_allowed=True):
67
66
  pkg_toml_config["tool"]["pdm"]["dev-dependencies"] = pkg_deps
68
67
  python_version_pattern = r"\s*W*(\d\.\d*)"
69
68
  requires_python = our_toml_config["project"]["requires-python"]
70
- our_python_version = re.search(python_version_pattern, requires_python).group(1)
71
69
  classifiers = []
72
70
  for classifier in pkg_toml_config["project"]["classifiers"]:
73
71
  classifier = re.sub(
74
- python_version_pattern, f" {our_python_version}", classifier
72
+ python_version_pattern, f" {self.config.python_version}", classifier
75
73
  )
76
74
  classifiers.append(classifier)
77
75
  pkg_toml_config["project"]["classifiers"] = classifiers
@@ -83,6 +81,7 @@ class Crakerjack(BaseModel, arbitrary_types_allowed=True):
83
81
  ".gitignore",
84
82
  ".pre-commit-config.yaml",
85
83
  ".libcst.codemod.yaml",
84
+ ".crackerjack.yaml",
86
85
  )
87
86
  for config in config_files:
88
87
  config_path = self.our_path / config
@@ -95,13 +94,14 @@ class Crakerjack(BaseModel, arbitrary_types_allowed=True):
95
94
  await pkg_config_path.write_text(
96
95
  config_text.replace("crackerjack", self.pkg_name)
97
96
  )
98
- run([commands.git, "add", config])
97
+ run([str(str(self.config.git_path)), "add", config])
99
98
 
100
- @staticmethod
101
- async def run_interactive(hook: str) -> None:
99
+ async def run_interactive(self, hook: str) -> None:
102
100
  success: bool = False
103
101
  while not success:
104
- fail = run([commands.pre_commit, "run", hook.lower(), "--all-files"])
102
+ fail = run(
103
+ [str(self.config.pre_commit_path), "run", hook.lower(), "--all-files"]
104
+ )
105
105
  if fail.returncode > 0:
106
106
  retry = await ainput(f"\n\n{hook.title()} failed. Retry? (y/N): ")
107
107
  await aprint()
@@ -113,53 +113,72 @@ class Crakerjack(BaseModel, arbitrary_types_allowed=True):
113
113
  async def update_pkg_configs(self) -> None:
114
114
  await self.copy_configs()
115
115
  installed_pkgs = run(
116
- [commands.pdm, "list", "--freeze"], capture_output=True, text=True
116
+ [str(str(self.config.pdm_path)), "list", "--freeze"],
117
+ capture_output=True,
118
+ text=True,
117
119
  ).stdout.splitlines()
118
120
  if not len([pkg for pkg in installed_pkgs if "pre-commit" in pkg]):
119
- run([commands.pdm, "self", "add", "keyring"])
120
- run([commands.pdm, "config", "python.use_venv", "false"])
121
- run([commands.git, "init"])
122
- run([commands.git, "branch", "-m", "main"])
123
- run([commands.git, "add", "pyproject.toml"])
124
- run([commands.pdm, "add", "-d", "pre_commit"])
125
- run([commands.pdm, "add", "-d", "pytest"])
126
- run([commands.pdm, "add", "-d", "autotyping"])
127
- run([commands.pre_commit, "install"])
128
- run([commands.git, "add", "pdm.lock"])
129
- run([commands.git, "config", "advice.addIgnoredFile", "false"])
121
+ await asyncio.create_subprocess_shell(
122
+ f"pdm --pep582 >> {self.config.zshenv_path}"
123
+ )
124
+ await asyncio.create_subprocess_shell(f"source {self.config.zshenv_path}")
125
+ run([str(str(self.config.pdm_path)), "self", "add", "keyring"])
126
+ run([str(str(self.config.pdm_path)), "config", "python.use_venv", "false"])
127
+ run([str(str(self.config.git_path)), "init"])
128
+ run([str(str(self.config.git_path)), "branch", "-m", "main"])
129
+ run([str(str(self.config.git_path)), "add", "pyproject.toml"])
130
+ run([str(str(self.config.pdm_path)), "add", "-d", "pre_commit"])
131
+ run([str(str(self.config.pdm_path)), "add", "-d", "pytest"])
132
+ run([str(str(self.config.pdm_path)), "add", "-d", "autotyping"])
133
+ run([str(self.config.pre_commit_path), "install"])
134
+ run([str(str(self.config.git_path)), "add", "pdm.lock"])
135
+ run(
136
+ [
137
+ str(str(self.config.git_path)),
138
+ "config",
139
+ "advice.addIgnoredFile",
140
+ "false",
141
+ ]
142
+ )
130
143
  await self.update_pyproject_configs()
131
144
 
132
145
  async def process(self, options: t.Any) -> None:
133
- imp_dir = self.pkg_path / "__pypackages__"
146
+ await self.settings_path.touch(exist_ok=True)
147
+ try:
148
+ self.config = Config(**await load.yaml(self.settings_path))
149
+ except TypeError:
150
+ self.config = Config()
151
+ await dump.yaml(self.config.model_dump(), self.settings_path)
152
+ raise SystemExit("\nPlease configure '.crackerjack.yaml' and try again\n")
153
+ imp_dir = self.pkg_path / "__pypackages__" / self.config.python_version / "lib"
134
154
  sys.path.append(str(imp_dir))
135
155
  self.pkg_name = underscore(self.pkg_path.stem.lower())
136
156
  self.pkg_dir = self.pkg_path / self.pkg_name
137
157
  await self.pkg_dir.mkdir(exist_ok=True)
138
158
  await aprint("\nCrackerjacking...\n")
139
159
  if self.pkg_path.stem == "crackerjack" and options.update_precommit:
140
- run([commands.pre_commit, "autoupdate"])
141
- await asyncio.create_subprocess_shell('eval "$(pdm --pep582)"')
160
+ run([str(self.config.pre_commit_path), "autoupdate"])
142
161
  if not options.do_not_update_configs:
143
162
  await self.update_pkg_configs()
144
- run([commands.pdm, "install"])
163
+ run([str(str(self.config.pdm_path)), "install"])
145
164
  if options.interactive:
146
165
  for hook in ("refurb", "bandit", "pyright"):
147
166
  await self.run_interactive(hook)
148
- check_all = run([commands.pre_commit, "run", "--all-files"])
167
+ check_all = run([str(self.config.pre_commit_path), "run", "--all-files"])
149
168
  if check_all.returncode > 0:
150
- check_all = run([commands.pre_commit, "run", "--all-files"])
169
+ check_all = run([str(self.config.pre_commit_path), "run", "--all-files"])
151
170
  if check_all.returncode > 0:
152
171
  await aprint("\n\nPre-commit failed. Please fix errors.\n")
153
172
  raise SystemExit()
154
173
  if options.publish:
155
- run([commands.pdm, "bump", options.publish])
174
+ run([str(str(self.config.pdm_path)), "bump", options.publish])
156
175
  if options.publish:
157
- run([commands.pdm, "publish"])
176
+ run([str(str(self.config.pdm_path)), "publish"])
158
177
  if options.commit:
159
178
  commit_msg = await ainput("\nCommit message: ")
160
179
  run(
161
180
  [
162
- commands.git,
181
+ str(str(self.config.git_path)),
163
182
  "commit",
164
183
  "-m",
165
184
  f"{commit_msg}",
@@ -168,7 +187,7 @@ class Crakerjack(BaseModel, arbitrary_types_allowed=True):
168
187
  ".",
169
188
  ]
170
189
  )
171
- run([commands.git, "push", "origin", "main"])
190
+ run([str(str(self.config.git_path)), "push", "origin", "main"])
172
191
  await aprint("\nCrackerjack complete!\n")
173
192
 
174
193
  async def run(self, options: t.Any) -> None:
@@ -53,9 +53,13 @@ skips = [
53
53
  ]
54
54
 
55
55
  [tool.pyright]
56
+ verboseOutput = true
56
57
  include = [
57
58
  "crackerjack",
58
59
  ]
60
+ extraPaths = [
61
+ "__pypackages__/3.12/lib/",
62
+ ]
59
63
  typeCheckingMode = "strict"
60
64
  reportMissingTypeStubs = false
61
65
  reportOptionalMemberAccess = false
@@ -65,10 +69,11 @@ reportUnknownVariableType = false
65
69
  reportUnknownArgumentType = false
66
70
  reportPrivateUsage = "warning"
67
71
  pythonVersion = "3.12"
72
+ pythonPlatform = "Darwin"
68
73
 
69
74
  [project]
70
75
  name = "Crackerjack"
71
- version = "0.7.4"
76
+ version = "0.7.5"
72
77
  description = "Crackerjack code style"
73
78
  requires-python = ">=3.12"
74
79
  readme = "README.md"
@@ -103,7 +108,7 @@ dependencies = [
103
108
  "pytest>=7.4.2",
104
109
  "pydantic>=2.4.0",
105
110
  "aiopath>=0.7.5",
106
- "acb>=0.3.3",
111
+ "acb>=0.3.4",
107
112
  ]
108
113
  authors = [
109
114
  { name = "lesleslie", email = "les@wedgwoodwebworks.com" },
@@ -53,9 +53,13 @@ skips = [
53
53
  ]
54
54
 
55
55
  [tool.pyright]
56
+ verboseOutput = true
56
57
  include = [
57
58
  "crackerjack",
58
59
  ]
60
+ extraPaths = [
61
+ "__pypackages__/3.12/lib/",
62
+ ]
59
63
  typeCheckingMode = "strict"
60
64
  reportMissingTypeStubs = false
61
65
  reportOptionalMemberAccess = false
@@ -65,10 +69,11 @@ reportUnknownVariableType = false
65
69
  reportUnknownArgumentType = false
66
70
  reportPrivateUsage = "warning"
67
71
  pythonVersion = "3.12"
72
+ pythonPlatform = "Darwin"
68
73
 
69
74
  [project]
70
75
  name = "Crackerjack"
71
- version = "0.7.3"
76
+ version = "0.7.6"
72
77
  description = "Crackerjack code style"
73
78
  requires-python = ">=3.12"
74
79
  readme = "README.md"
@@ -103,7 +108,7 @@ dependencies = [
103
108
  "pytest>=7.4.2",
104
109
  "pydantic>=2.4.0",
105
110
  "aiopath>=0.7.5",
106
- "acb>=0.3.3",
111
+ "acb>=0.3.4",
107
112
  ]
108
113
  authors = [
109
114
  { name = "lesleslie", email = "les@wedgwoodwebworks.com" },
File without changes
File without changes