winipedia-utils 0.3.9__tar.gz → 0.3.22__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.

Potentially problematic release.


This version of winipedia-utils might be problematic. Click here for more details.

Files changed (90) hide show
  1. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/PKG-INFO +22 -34
  2. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/README.md +21 -33
  3. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/pyproject.toml +1 -1
  4. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/git/gitignore/config.py +1 -1
  5. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/git/pre_commit/config.py +2 -4
  6. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/git/pre_commit/hooks.py +20 -18
  7. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/git/pre_commit/run_hooks.py +1 -5
  8. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/git/workflows/base/base.py +17 -9
  9. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/git/workflows/publish.py +1 -2
  10. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/git/workflows/release.py +11 -5
  11. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/iterating/iterate.py +1 -1
  12. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/modules/package.py +36 -6
  13. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/projects/poetry/config.py +1 -2
  14. winipedia_utils-0.3.22/winipedia_utils/projects/poetry/poetry.py +42 -0
  15. winipedia_utils-0.3.22/winipedia_utils/projects/project.py +17 -0
  16. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/setup.py +2 -4
  17. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/text/config.py +10 -0
  18. winipedia_utils-0.3.9/winipedia_utils/projects/poetry/poetry.py +0 -24
  19. winipedia_utils-0.3.9/winipedia_utils/projects/project.py +0 -42
  20. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/LICENSE +0 -0
  21. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/__init__.py +0 -0
  22. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/concurrent/__init__.py +0 -0
  23. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/concurrent/concurrent.py +0 -0
  24. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/concurrent/multiprocessing.py +0 -0
  25. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/concurrent/multithreading.py +0 -0
  26. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/data/__init__.py +0 -0
  27. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/data/dataframe/__init__.py +0 -0
  28. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/data/dataframe/cleaning.py +0 -0
  29. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/data/structures/__init__.py +0 -0
  30. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/data/structures/dicts.py +0 -0
  31. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/git/__init__.py +0 -0
  32. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/git/gitignore/__init__.py +0 -0
  33. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/git/gitignore/gitignore.py +0 -0
  34. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/git/pre_commit/__init__.py +0 -0
  35. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/git/workflows/__init__.py +0 -0
  36. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/git/workflows/base/__init__.py +0 -0
  37. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/iterating/__init__.py +0 -0
  38. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/logging/__init__.py +0 -0
  39. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/logging/ansi.py +0 -0
  40. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/logging/config.py +0 -0
  41. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/logging/logger.py +0 -0
  42. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/modules/__init__.py +0 -0
  43. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/modules/class_.py +0 -0
  44. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/modules/function.py +0 -0
  45. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/modules/module.py +0 -0
  46. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/oop/__init__.py +0 -0
  47. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/oop/mixins/__init__.py +0 -0
  48. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/oop/mixins/meta.py +0 -0
  49. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/oop/mixins/mixin.py +0 -0
  50. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/os/__init__.py +0 -0
  51. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/os/os.py +0 -0
  52. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/projects/__init__.py +0 -0
  53. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/projects/poetry/__init__.py +0 -0
  54. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/py.typed +0 -0
  55. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/resources/__init__.py +0 -0
  56. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/resources/svgs/__init__.py +0 -0
  57. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/resources/svgs/delete_garbage_can.svg +0 -0
  58. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/resources/svgs/download_arrow.svg +0 -0
  59. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/resources/svgs/exit_fullscreen_icon.svg +0 -0
  60. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/resources/svgs/fullscreen_icon.svg +0 -0
  61. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/resources/svgs/menu_icon.svg +0 -0
  62. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/resources/svgs/pause_icon.svg +0 -0
  63. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/resources/svgs/play_icon.svg +0 -0
  64. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/resources/svgs/plus_icon.svg +0 -0
  65. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/resources/svgs/svg.py +0 -0
  66. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/security/__init__.py +0 -0
  67. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/security/cryptography.py +0 -0
  68. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/security/keyring.py +0 -0
  69. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/__init__.py +0 -0
  70. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/assertions.py +0 -0
  71. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/config.py +0 -0
  72. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/convention.py +0 -0
  73. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/create_tests.py +0 -0
  74. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/fixtures.py +0 -0
  75. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/skip.py +0 -0
  76. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/tests/__init__.py +0 -0
  77. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/tests/base/__init__.py +0 -0
  78. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/tests/base/fixtures/__init__.py +0 -0
  79. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/tests/base/fixtures/fixture.py +0 -0
  80. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/tests/base/fixtures/scopes/__init__.py +0 -0
  81. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/tests/base/fixtures/scopes/class_.py +0 -0
  82. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/tests/base/fixtures/scopes/function.py +0 -0
  83. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/tests/base/fixtures/scopes/module.py +0 -0
  84. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/tests/base/fixtures/scopes/package.py +0 -0
  85. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/tests/base/fixtures/scopes/session.py +0 -0
  86. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/tests/base/utils/__init__.py +0 -0
  87. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/tests/base/utils/utils.py +0 -0
  88. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/testing/tests/conftest.py +0 -0
  89. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/text/__init__.py +0 -0
  90. {winipedia_utils-0.3.9 → winipedia_utils-0.3.22}/winipedia_utils/text/string.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: winipedia-utils
3
- Version: 0.3.9
3
+ Version: 0.3.22
4
4
  Summary: A package with many utility functions
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -88,8 +88,8 @@ The setup creates the following configuration files:
88
88
  - `.pre-commit-config.yaml` - Pre-commit hook configuration
89
89
  - `.gitignore` - Git ignore rules (assumes you added one on GitHub before.)
90
90
  - `pyproject.toml` - Project configuration with Poetry settings
91
- - `.github/workflows/release.yaml` - Release workflow
92
- - `.github/workflows/publish.yaml` - Publishing workflow
91
+ - `.github/workflows/release.yaml` - Release workflow (Creates a release on GitHub when oushing to main)
92
+ - `.github/workflows/publish.yaml` - Publishing workflow (Publishes to PyPI when a release is created by the release workflow)
93
93
  - `py.typed` - PEP 561 marker for type hints
94
94
  - `experiment.py` - For experimentation (ignored by git)
95
95
  - `test0.py` - Test file with one empyt test (so that initial tests pass)
@@ -97,21 +97,25 @@ The setup creates the following configuration files:
97
97
 
98
98
  ### Pre-commit Hook Workflow
99
99
 
100
- When you commit code using `poetry run git commit`, the following checks run automatically:
101
-
102
- 1. Patch version
103
- 2. Add version patch to git
104
- 3. Update package manager
105
- 4. Install packages
106
- 5. Update packages
107
- 6. Lock dependencies
108
- 7. Check package manager configs
109
- 8. Create tests
110
- 9. Lint code
111
- 10. Format code
112
- 11. Check static types
113
- 12. Check security
114
- 13. Run tests
100
+ When you commit code using `git commit`, the following checks run automatically:
101
+
102
+ Info: If git commit fails bc of ModuleNotFoundError or smth similar, you need to run `poetry run git commit` instead.
103
+ winipedia_utils hook is a python script that depends on winipedia_utils being installed. Poetry is needed to install winipedia_utils.
104
+ Usually VSCode or other IDEs activates the venv automatically when opening the terminal but if not you need to activate it manually or run `poetry run git commit` instead.
105
+
106
+ 1. Patch version (poetry version patch)
107
+ 2. Add version patch to git (git add pyproject.toml)
108
+ 3. Update package manager (poetry self update)
109
+ 4. Install packages (poetry install)
110
+ 5. Update packages (poetry update)
111
+ 6. Lock dependencies (poetry lock)
112
+ 7. Check package manager configs (poetry check --strict)
113
+ 8. Create tests (python -m winipedia_utils.testing.create_tests)
114
+ 9. Lint code (ruff check --fix)
115
+ 10. Format code (ruff format)
116
+ 11. Check static types (mypy)
117
+ 12. Check security (bandit -c pyproject.toml -r .)
118
+ 13. Run tests (pytest (uses pyproject.toml as config))
115
119
 
116
120
  ### Auto-generated Test Structure
117
121
 
@@ -283,22 +287,6 @@ from winipedia_utils.projects.project import create_project_root
283
287
  from winipedia_utils.projects.poetry.config import PyProjectTomlConfig
284
288
  ```
285
289
 
286
- ## Important Notes
287
-
288
- ### Git Commit Workflow
289
-
290
- When using winipedia-utils, you **must** use Poetry to run git commit:
291
-
292
- ```bash
293
- # Correct - Uses Python environment for pre-commit hook
294
- poetry run git commit -m "Your commit message"
295
-
296
- # Incorrect - Pre-commit hook won't run properly
297
- git commit -m "Your commit message"
298
- ```
299
-
300
- This is necessary because the pre-commit hook needs access to the Python environment and installed packages.
301
-
302
290
  ### Philosophy
303
291
 
304
292
  The core philosophy of Winipedia Utils is to:
@@ -64,8 +64,8 @@ The setup creates the following configuration files:
64
64
  - `.pre-commit-config.yaml` - Pre-commit hook configuration
65
65
  - `.gitignore` - Git ignore rules (assumes you added one on GitHub before.)
66
66
  - `pyproject.toml` - Project configuration with Poetry settings
67
- - `.github/workflows/release.yaml` - Release workflow
68
- - `.github/workflows/publish.yaml` - Publishing workflow
67
+ - `.github/workflows/release.yaml` - Release workflow (Creates a release on GitHub when oushing to main)
68
+ - `.github/workflows/publish.yaml` - Publishing workflow (Publishes to PyPI when a release is created by the release workflow)
69
69
  - `py.typed` - PEP 561 marker for type hints
70
70
  - `experiment.py` - For experimentation (ignored by git)
71
71
  - `test0.py` - Test file with one empyt test (so that initial tests pass)
@@ -73,21 +73,25 @@ The setup creates the following configuration files:
73
73
 
74
74
  ### Pre-commit Hook Workflow
75
75
 
76
- When you commit code using `poetry run git commit`, the following checks run automatically:
77
-
78
- 1. Patch version
79
- 2. Add version patch to git
80
- 3. Update package manager
81
- 4. Install packages
82
- 5. Update packages
83
- 6. Lock dependencies
84
- 7. Check package manager configs
85
- 8. Create tests
86
- 9. Lint code
87
- 10. Format code
88
- 11. Check static types
89
- 12. Check security
90
- 13. Run tests
76
+ When you commit code using `git commit`, the following checks run automatically:
77
+
78
+ Info: If git commit fails bc of ModuleNotFoundError or smth similar, you need to run `poetry run git commit` instead.
79
+ winipedia_utils hook is a python script that depends on winipedia_utils being installed. Poetry is needed to install winipedia_utils.
80
+ Usually VSCode or other IDEs activates the venv automatically when opening the terminal but if not you need to activate it manually or run `poetry run git commit` instead.
81
+
82
+ 1. Patch version (poetry version patch)
83
+ 2. Add version patch to git (git add pyproject.toml)
84
+ 3. Update package manager (poetry self update)
85
+ 4. Install packages (poetry install)
86
+ 5. Update packages (poetry update)
87
+ 6. Lock dependencies (poetry lock)
88
+ 7. Check package manager configs (poetry check --strict)
89
+ 8. Create tests (python -m winipedia_utils.testing.create_tests)
90
+ 9. Lint code (ruff check --fix)
91
+ 10. Format code (ruff format)
92
+ 11. Check static types (mypy)
93
+ 12. Check security (bandit -c pyproject.toml -r .)
94
+ 13. Run tests (pytest (uses pyproject.toml as config))
91
95
 
92
96
  ### Auto-generated Test Structure
93
97
 
@@ -259,22 +263,6 @@ from winipedia_utils.projects.project import create_project_root
259
263
  from winipedia_utils.projects.poetry.config import PyProjectTomlConfig
260
264
  ```
261
265
 
262
- ## Important Notes
263
-
264
- ### Git Commit Workflow
265
-
266
- When using winipedia-utils, you **must** use Poetry to run git commit:
267
-
268
- ```bash
269
- # Correct - Uses Python environment for pre-commit hook
270
- poetry run git commit -m "Your commit message"
271
-
272
- # Incorrect - Pre-commit hook won't run properly
273
- git commit -m "Your commit message"
274
- ```
275
-
276
- This is necessary because the pre-commit hook needs access to the Python environment and installed packages.
277
-
278
266
  ### Philosophy
279
267
 
280
268
  The core philosophy of Winipedia Utils is to:
@@ -1,7 +1,7 @@
1
1
  # Project section
2
2
  [project]
3
3
  name = "winipedia-utils"
4
- version = "0.3.9"
4
+ version = "0.3.22"
5
5
  description = "A package with many utility functions"
6
6
  readme = "README.md"
7
7
  requires-python = ">=3.12"
@@ -22,7 +22,7 @@ class GitIgnoreConfigFile(ConfigFile):
22
22
  return self.load_static()
23
23
 
24
24
  @classmethod
25
- def load_static(cls) -> dict[str, Any]:
25
+ def load_static(cls) -> dict[str, list[str]]:
26
26
  """Load the config file."""
27
27
  paths = cls.PATH.read_text().splitlines()
28
28
  return {cls.IGNORE_KEY: paths}
@@ -4,12 +4,10 @@ from pathlib import Path
4
4
  from typing import Any
5
5
 
6
6
  import winipedia_utils
7
- from winipedia_utils.git.pre_commit import run_hooks
8
7
  from winipedia_utils.logging.logger import get_logger
9
- from winipedia_utils.modules.module import make_obj_importpath
8
+ from winipedia_utils.modules.package import make_name_from_package
10
9
  from winipedia_utils.os.os import run_subprocess
11
10
  from winipedia_utils.projects.poetry.poetry import POETRY_RUN_ARGS
12
- from winipedia_utils.projects.project import make_name_from_package
13
11
  from winipedia_utils.text.config import YamlConfigFile
14
12
 
15
13
  logger = get_logger(__name__)
@@ -40,7 +38,7 @@ class PreCommitConfigFile(YamlConfigFile):
40
38
  {
41
39
  "id": hook_name,
42
40
  "name": hook_name,
43
- "entry": f"python -m {make_obj_importpath(run_hooks)}",
41
+ "entry": self.get_python_setup_script(),
44
42
  "language": "system",
45
43
  "always_run": True,
46
44
  "pass_filenames": False,
@@ -10,10 +10,8 @@ run_hooks.py, which will pass the returned list to subprocess.run().
10
10
  from pathlib import Path
11
11
 
12
12
  from winipedia_utils.projects.poetry.poetry import (
13
- POETRY_PATH,
14
- POETRY_RUN_ARGS,
15
- POETRY_RUN_PYTHON_ARGS,
16
- POETRY_RUN_RUFF_ARGS,
13
+ POETRY_ARG,
14
+ get_run_python_module_args,
17
15
  )
18
16
 
19
17
 
@@ -23,7 +21,7 @@ def patch_version() -> list[str | Path]:
23
21
  This function returns the input for subprocess.run() to patch the version
24
22
  in pyproject.toml.
25
23
  """
26
- return [POETRY_PATH, "version", "patch"]
24
+ return [POETRY_ARG, "version", "patch"]
27
25
 
28
26
 
29
27
  def add_version_patch_to_git() -> list[str | Path]:
@@ -32,7 +30,7 @@ def add_version_patch_to_git() -> list[str | Path]:
32
30
  This function returns the input for subprocess.run() to add the version
33
31
  patch to git, so that the hook does not fail bc the file was changed.
34
32
  """
35
- return [*POETRY_RUN_ARGS, "git", "add", "pyproject.toml"]
33
+ return ["git", "add", "pyproject.toml"]
36
34
 
37
35
 
38
36
  def update_package_manager() -> list[str | Path]:
@@ -41,7 +39,7 @@ def update_package_manager() -> list[str | Path]:
41
39
  This function returns the input for subprocess.run() to update the package
42
40
  manager.
43
41
  """
44
- return [POETRY_PATH, "self", "update"]
42
+ return [POETRY_ARG, "self", "update"]
45
43
 
46
44
 
47
45
  def install_packages() -> list[str | Path]:
@@ -49,7 +47,7 @@ def install_packages() -> list[str | Path]:
49
47
 
50
48
  This function returns the input for subprocess.run() to install all dependencies.
51
49
  """
52
- return [POETRY_PATH, "install"]
50
+ return [POETRY_ARG, "install"]
53
51
 
54
52
 
55
53
  def update_packages() -> list[str | Path]:
@@ -57,7 +55,7 @@ def update_packages() -> list[str | Path]:
57
55
 
58
56
  This function returns the input for subprocess.run() to update all dependencies.
59
57
  """
60
- return [POETRY_PATH, "update"]
58
+ return [POETRY_ARG, "update"]
61
59
 
62
60
 
63
61
  def lock_dependencies() -> list[str | Path]:
@@ -65,7 +63,7 @@ def lock_dependencies() -> list[str | Path]:
65
63
 
66
64
  This function returns the input for subprocess.run() to lock the dependencies.
67
65
  """
68
- return [POETRY_PATH, "lock"]
66
+ return [POETRY_ARG, "lock"]
69
67
 
70
68
 
71
69
  def check_package_manager_configs() -> list[str | Path]:
@@ -74,15 +72,19 @@ def check_package_manager_configs() -> list[str | Path]:
74
72
  This function returns the input for subprocess.run() to check that poetry.lock
75
73
  is up to date.
76
74
  """
77
- return [POETRY_PATH, "check", "--strict"]
75
+ return [POETRY_ARG, "check", "--strict"]
78
76
 
79
77
 
80
- def create_tests() -> list[str | Path]:
78
+ def create_missing_tests() -> list[str | Path]:
81
79
  """Create all tests for the project.
82
80
 
83
81
  This function returns the input for subprocess.run() to create all tests.
84
82
  """
85
- return [*POETRY_RUN_PYTHON_ARGS, "-m", "winipedia_utils.testing.create_tests"]
83
+ from winipedia_utils.testing import ( # noqa: PLC0415 # avoid circular import
84
+ create_tests,
85
+ )
86
+
87
+ return [*get_run_python_module_args(create_tests)]
86
88
 
87
89
 
88
90
  def lint_code() -> list[str | Path]:
@@ -91,7 +93,7 @@ def lint_code() -> list[str | Path]:
91
93
  This function returns the input for subprocess.run() to lint the code.
92
94
  It autofixes all errors that can be autofixed with --fix.
93
95
  """
94
- return [*POETRY_RUN_RUFF_ARGS, "check", "--fix"]
96
+ return ["ruff", "check", "--fix"]
95
97
 
96
98
 
97
99
  def format_code() -> list[str | Path]:
@@ -99,7 +101,7 @@ def format_code() -> list[str | Path]:
99
101
 
100
102
  This function calls ruff format to format the code.
101
103
  """
102
- return [*POETRY_RUN_RUFF_ARGS, "format"]
104
+ return ["ruff", "format"]
103
105
 
104
106
 
105
107
  def check_static_types() -> list[str | Path]:
@@ -107,7 +109,7 @@ def check_static_types() -> list[str | Path]:
107
109
 
108
110
  This function returns the input for subprocess.run() to check the static types.
109
111
  """
110
- return [*POETRY_RUN_ARGS, "mypy"]
112
+ return ["mypy"]
111
113
 
112
114
 
113
115
  def check_security() -> list[str | Path]:
@@ -116,7 +118,7 @@ def check_security() -> list[str | Path]:
116
118
  This function returns the input for subprocess.run() to check the security of
117
119
  the code.
118
120
  """
119
- return [*POETRY_RUN_ARGS, "bandit", "-c", "pyproject.toml", "-r", "."]
121
+ return ["bandit", "-c", "pyproject.toml", "-r", "."]
120
122
 
121
123
 
122
124
  def run_tests() -> list[str | Path]:
@@ -124,4 +126,4 @@ def run_tests() -> list[str | Path]:
124
126
 
125
127
  This function returns the input for subprocess.run() to run all tests.
126
128
  """
127
- return [*POETRY_RUN_ARGS, "pytest"]
129
+ return ["pytest"]
@@ -15,7 +15,7 @@ from winipedia_utils.os.os import run_subprocess
15
15
  logger = get_logger(__name__)
16
16
 
17
17
 
18
- def run_all() -> None:
18
+ def run_hooks() -> None:
19
19
  """Import all funcs defined in hooks.py and runs them."""
20
20
  hook_funcs = get_all_functions_from_module(hooks)
21
21
 
@@ -43,7 +43,3 @@ def run_all() -> None:
43
43
  )
44
44
 
45
45
  sys.exit(exit_code)
46
-
47
-
48
- if __name__ == "__main__":
49
- run_all()
@@ -29,7 +29,7 @@ class Workflow(YamlConfigFile):
29
29
 
30
30
  def get_run_name(self) -> str:
31
31
  """Get the workflow run name."""
32
- return self.get_workflow_name() + self.get_repo_and_ref_name_formatted()
32
+ return f"{self.get_workflow_name()}"
33
33
 
34
34
  def get_configs(self) -> dict[str, Any]:
35
35
  """Get the workflow config."""
@@ -103,6 +103,13 @@ class Workflow(YamlConfigFile):
103
103
  "run": "curl -sSL https://install.python-poetry.org | python3 -",
104
104
  }
105
105
  )
106
+ steps.append(
107
+ {
108
+ "name": "Extract Version from pyproject.toml",
109
+ "id": "version",
110
+ "run": 'version=$(poetry version -s) && echo "Project version: $version" && echo "version=v$version" >> $GITHUB_OUTPUT', # noqa: E501
111
+ },
112
+ )
106
113
  if configure_pipy_token:
107
114
  steps.append(
108
115
  {
@@ -119,16 +126,17 @@ class Workflow(YamlConfigFile):
119
126
  """Get the repository name."""
120
127
  return "${{ github.event.repository.name }}"
121
128
 
122
- def get_ref_name(self) -> str:
129
+ @staticmethod
130
+ def get_ref_name() -> str:
123
131
  """Get the ref name."""
124
132
  return "${{ github.ref_name }}"
125
133
 
126
- @staticmethod
127
- def get_repo_and_ref_name() -> str:
128
- """Get the repository name and ref name."""
129
- return "${{ github.event.repository.name }}-${{ github.ref_name }}"
130
-
131
134
  @classmethod
132
- def get_repo_and_ref_name_formatted(cls) -> str:
135
+ def get_version(cls) -> str:
136
+ """Get the version."""
137
+ return "${{ steps.version.outputs.version }}"
138
+
139
+ @staticmethod
140
+ def get_repo_and_version() -> str:
133
141
  """Get the repository name and ref name."""
134
- return f": {cls.get_repo_and_ref_name()}"
142
+ return f"{Workflow.get_repository_name()} {Workflow.get_version()}"
@@ -47,8 +47,7 @@ class PublishWorkflow(Workflow):
47
47
  )
48
48
  ),
49
49
  {
50
- "name": "Build and publish to PyPI"
51
- + self.get_repo_and_ref_name_formatted(),
50
+ "name": "Build and publish to PyPI",
52
51
  "run": "poetry publish --build",
53
52
  },
54
53
  ],
@@ -20,7 +20,7 @@ class ReleaseWorkflow(Workflow):
20
20
 
21
21
  def get_workflow_triggers(self) -> dict[str, Any]:
22
22
  """Get the workflow triggers."""
23
- return {"push": {"tags": ["v*"]}}
23
+ return {"push": {"branches": ["main"]}}
24
24
 
25
25
  def get_permissions(self) -> dict[str, Any]:
26
26
  """Get the workflow permissions."""
@@ -38,13 +38,19 @@ class ReleaseWorkflow(Workflow):
38
38
  self.get_poetry_setup_steps(
39
39
  install_dependencies=True,
40
40
  fetch_depth=0,
41
- force_main_head=True,
42
41
  )
43
42
  ),
44
43
  {
45
- "name": "Run Pre-commit Hooks",
44
+ # using pre commit in case other hooks are added later
45
+ # and bc it fails if files are changed,
46
+ # setup script shouldnt change files
47
+ "name": "Run Hooks",
46
48
  "run": "poetry run pre-commit run",
47
49
  },
50
+ {
51
+ "name": "Create and Push Tag",
52
+ "run": f"git tag {self.get_version()} && git push origin {self.get_version()}", # noqa: E501
53
+ },
48
54
  {
49
55
  "name": "Build Changelog",
50
56
  "id": "build_changelog",
@@ -55,8 +61,8 @@ class ReleaseWorkflow(Workflow):
55
61
  "name": "Create GitHub Release",
56
62
  "uses": "ncipollo/release-action@v1",
57
63
  "with": {
58
- "tag": "${{ github.ref_name }}",
59
- "name": self.get_repo_and_ref_name(),
64
+ "tag": self.get_version(),
65
+ "name": self.get_repo_and_version(),
60
66
  "body": "${{ steps.build_changelog.outputs.changelog }}",
61
67
  },
62
68
  },
@@ -70,7 +70,7 @@ def nested_structure_is_subset(
70
70
  """Get actual value from superset."""
71
71
  return superset[key_or_index] if key_or_index < len(superset) else None
72
72
  else:
73
- return (subset == superset) or (subset is Any)
73
+ return subset == superset
74
74
 
75
75
  all_good = True
76
76
  for key_or_index, value in iterable:
@@ -20,10 +20,6 @@ from types import ModuleType
20
20
  from setuptools import find_namespace_packages as _find_namespace_packages
21
21
  from setuptools import find_packages as _find_packages
22
22
 
23
- from winipedia_utils.git.gitignore.config import GitIgnoreConfigFile
24
- from winipedia_utils.git.gitignore.gitignore import (
25
- walk_os_skipping_gitignore_patterns,
26
- )
27
23
  from winipedia_utils.logging.logger import get_logger
28
24
 
29
25
  logger = get_logger(__name__)
@@ -182,6 +178,10 @@ def find_packages(
182
178
  find_packages(depth=1) might return ["package1", "package2"]
183
179
 
184
180
  """
181
+ from winipedia_utils.git.gitignore.config import ( # noqa: PLC0415
182
+ GitIgnoreConfigFile, # avoid circular import
183
+ )
184
+
185
185
  if exclude is None:
186
186
  exclude = GitIgnoreConfigFile.load_static()[GitIgnoreConfigFile.IGNORE_KEY]
187
187
  exclude = [
@@ -282,8 +282,11 @@ def make_init_modules_for_package(path: str | Path | ModuleType) -> None:
282
282
  from get_default_init_module_content.
283
283
 
284
284
  """
285
- from winipedia_utils.modules.module import ( # noqa: PLC0415 # avoid circular import
286
- to_path,
285
+ from winipedia_utils.git.gitignore.gitignore import ( # noqa: PLC0415
286
+ walk_os_skipping_gitignore_patterns, # avoid circular import
287
+ )
288
+ from winipedia_utils.modules.module import ( # noqa: PLC0415
289
+ to_path, # avoid circular import
287
290
  )
288
291
 
289
292
  path = to_path(path, is_package=True)
@@ -397,3 +400,30 @@ def get_main_package() -> ModuleType:
397
400
 
398
401
  msg = "Not able to determine the main package"
399
402
  raise ValueError(msg)
403
+
404
+
405
+ def make_name_from_package(
406
+ package: ModuleType,
407
+ split_on: str = "_",
408
+ join_on: str = "-",
409
+ *,
410
+ capitalize: bool = True,
411
+ ) -> str:
412
+ """Make a name from a package.
413
+
414
+ takes a package and makes a name from it that is readable by humans.
415
+
416
+ Args:
417
+ package (ModuleType): The package to make a name from
418
+ split_on (str, optional): what to split the package name on. Defaults to "_".
419
+ join_on (str, optional): what to join the package name with. Defaults to "-".
420
+ capitalize (bool, optional): Whether to capitalize each part. Defaults to True.
421
+
422
+ Returns:
423
+ str: _description_
424
+ """
425
+ package_name = package.__name__.split(".")[-1]
426
+ parts = package_name.split(split_on)
427
+ if capitalize:
428
+ parts = [part.capitalize() for part in parts]
429
+ return join_on.join(parts)
@@ -3,8 +3,7 @@
3
3
  from pathlib import Path
4
4
  from typing import Any
5
5
 
6
- from winipedia_utils.modules.package import get_src_package
7
- from winipedia_utils.projects.project import make_name_from_package
6
+ from winipedia_utils.modules.package import get_src_package, make_name_from_package
8
7
  from winipedia_utils.testing.convention import TESTS_PACKAGE_NAME
9
8
  from winipedia_utils.text.config import ConfigFile, TomlConfigFile
10
9
 
@@ -0,0 +1,42 @@
1
+ """Project utilities for introspection and manipulation.
2
+
3
+ This module provides utility functions for working with Python projects
4
+ """
5
+
6
+ from collections.abc import Iterable
7
+ from types import ModuleType
8
+
9
+ from winipedia_utils.logging.logger import get_logger
10
+
11
+ logger = get_logger(__name__)
12
+
13
+
14
+ POETRY_ARG = "poetry"
15
+
16
+ POETRY_RUN_ARGS = [POETRY_ARG, "run"]
17
+
18
+ RUN_PYTHON_MODULE_ARGS = ["python", "-m"]
19
+
20
+
21
+ def get_script_from_args(args: Iterable[str]) -> str:
22
+ """Get the script from args."""
23
+ return " ".join(args)
24
+
25
+
26
+ def get_run_python_module_args(module: ModuleType) -> list[str]:
27
+ """Get the args to run a module."""
28
+ from winipedia_utils.modules.module import ( # noqa: PLC0415 # avoid circular import
29
+ make_obj_importpath,
30
+ )
31
+
32
+ return [*RUN_PYTHON_MODULE_ARGS, make_obj_importpath(module)]
33
+
34
+
35
+ def get_python_module_script(module: ModuleType) -> str:
36
+ """Get the script to run a module."""
37
+ return get_script_from_args(get_run_python_module_args(module))
38
+
39
+
40
+ def get_poetry_run_module_script(module: ModuleType) -> str:
41
+ """Get the script to run a module."""
42
+ return get_script_from_args([*POETRY_RUN_ARGS, *get_run_python_module_args(module)])
@@ -0,0 +1,17 @@
1
+ """Utilities for working with Python projects."""
2
+
3
+ from winipedia_utils.modules.module import create_module
4
+ from winipedia_utils.projects.poetry.config import (
5
+ PyProjectTomlConfig, # avoid circular import
6
+ )
7
+ from winipedia_utils.text.config import (
8
+ ConfigFile, # avoid circular import
9
+ )
10
+
11
+
12
+ def create_project_root() -> None:
13
+ """Create the project root."""
14
+ ConfigFile.init_config_files()
15
+
16
+ src_package_name = PyProjectTomlConfig().get_package_name()
17
+ create_module(src_package_name, is_package=True)
@@ -9,18 +9,16 @@ This script is intended to be called once at the beginning of a project.
9
9
  from collections.abc import Callable
10
10
  from typing import Any
11
11
 
12
- from winipedia_utils.git.pre_commit.run_hooks import run_all
12
+ from winipedia_utils.git.pre_commit.run_hooks import run_hooks
13
13
  from winipedia_utils.logging.logger import get_logger
14
14
  from winipedia_utils.projects.project import create_project_root
15
- from winipedia_utils.text.config import ConfigFile
16
15
 
17
16
  logger = get_logger(__name__)
18
17
 
19
18
 
20
19
  SETUP_STEPS: list[Callable[..., Any]] = [
21
- ConfigFile.init_config_files,
22
20
  create_project_root,
23
- run_all,
21
+ run_hooks,
24
22
  ]
25
23
 
26
24
 
@@ -10,6 +10,9 @@ import yaml
10
10
  import winipedia_utils
11
11
  from winipedia_utils.iterating.iterate import nested_structure_is_subset
12
12
  from winipedia_utils.modules.class_ import init_all_nonabstract_subclasses
13
+ from winipedia_utils.projects.poetry.poetry import (
14
+ get_python_module_script,
15
+ )
13
16
 
14
17
 
15
18
  class ConfigFile(ABC):
@@ -129,6 +132,13 @@ class YamlConfigFile(ConfigFile):
129
132
  with self.path.open("w") as f:
130
133
  yaml.safe_dump(config, f, sort_keys=False)
131
134
 
135
+ @staticmethod
136
+ def get_python_setup_script() -> str:
137
+ """Get the poetry run setup script."""
138
+ from winipedia_utils import setup # noqa: PLC0415 # avoid circular import
139
+
140
+ return get_python_module_script(setup)
141
+
132
142
 
133
143
  class TomlConfigFile(ConfigFile):
134
144
  """Base class for toml config files."""
@@ -1,24 +0,0 @@
1
- """Project utilities for introspection and manipulation.
2
-
3
- This module provides utility functions for working with Python projects
4
- """
5
-
6
- import sys
7
-
8
- from winipedia_utils.logging.logger import get_logger
9
- from winipedia_utils.os.os import which_with_raise
10
-
11
- logger = get_logger(__name__)
12
-
13
-
14
- POETRY_PATH = which_with_raise("poetry", raise_error=False) or "poetry"
15
-
16
- POETRY_RUN_ARGS = [POETRY_PATH, "run"]
17
-
18
- POETRY_ADD_ARGS = [POETRY_PATH, "add"]
19
-
20
- POETRY_ADD_DEV_ARGS = [*POETRY_ADD_ARGS, "--group", "dev"]
21
-
22
- POETRY_RUN_PYTHON_ARGS = [*POETRY_RUN_ARGS, sys.executable]
23
-
24
- POETRY_RUN_RUFF_ARGS = [*POETRY_RUN_ARGS, "ruff"]
@@ -1,42 +0,0 @@
1
- """Utilities for working with Python projects."""
2
-
3
- from types import ModuleType
4
-
5
- from winipedia_utils.modules.module import create_module
6
-
7
-
8
- def create_project_root() -> None:
9
- """Create the project root."""
10
- from winipedia_utils.projects.poetry.config import ( # noqa: PLC0415 # avoid circular import
11
- PyProjectTomlConfig,
12
- )
13
-
14
- src_package_name = PyProjectTomlConfig().get_package_name()
15
- create_module(src_package_name, is_package=True)
16
-
17
-
18
- def make_name_from_package(
19
- package: ModuleType,
20
- split_on: str = "_",
21
- join_on: str = "-",
22
- *,
23
- capitalize: bool = True,
24
- ) -> str:
25
- """Make a name from a package.
26
-
27
- takes a package and makes a name from it that is readable by humans.
28
-
29
- Args:
30
- package (ModuleType): The package to make a name from
31
- split_on (str, optional): what to split the package name on. Defaults to "_".
32
- join_on (str, optional): what to join the package name with. Defaults to "-".
33
- capitalize (bool, optional): Whether to capitalize each part. Defaults to True.
34
-
35
- Returns:
36
- str: _description_
37
- """
38
- package_name = package.__name__.split(".")[-1]
39
- parts = package_name.split(split_on)
40
- if capitalize:
41
- parts = [part.capitalize() for part in parts]
42
- return join_on.join(parts)