apdev 0.2.0__py3-none-any.whl → 0.2.2__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.
apdev/__init__.py CHANGED
@@ -1,3 +1,3 @@
1
1
  """apdev - Shared development tools for Python projects."""
2
2
 
3
- __version__ = "0.2.0"
3
+ __version__ = "0.2.2"
apdev/check_chars.py CHANGED
@@ -278,6 +278,141 @@ def check_file(
278
278
  return problems
279
279
 
280
280
 
281
+ _DEFAULT_DIRS = ("src", "tests", "examples")
282
+ _DEFAULT_GLOBS = ("*.md", "*.yml", "*.yaml", "*.json", ".gitignore")
283
+
284
+
285
+ def _resolve_paths(paths: list[Path]) -> list[Path]:
286
+ """Expand directories to files and deduplicate.
287
+
288
+ If *paths* is empty, scan default directories (src, tests, examples)
289
+ and common config files in the current working directory.
290
+ Directories are expanded recursively (hidden files/dirs and binary
291
+ files are skipped).
292
+ """
293
+ if not paths:
294
+ return _default_project_files()
295
+
296
+ result: list[Path] = []
297
+ for p in paths:
298
+ if p.is_dir():
299
+ result.extend(_walk_dir(p))
300
+ else:
301
+ result.append(p)
302
+ return result
303
+
304
+
305
+ def _default_project_files() -> list[Path]:
306
+ """Collect files from default project directories and root config files."""
307
+ cwd = Path.cwd()
308
+ files: list[Path] = []
309
+
310
+ for dirname in _DEFAULT_DIRS:
311
+ d = cwd / dirname
312
+ if d.is_dir():
313
+ files.extend(_walk_dir(d))
314
+
315
+ for pattern in _DEFAULT_GLOBS:
316
+ files.extend(sorted(cwd.glob(pattern)))
317
+
318
+ return files
319
+
320
+
321
+ _SKIP_SUFFIXES = frozenset(
322
+ {
323
+ # Python bytecode
324
+ ".pyc",
325
+ ".pyo",
326
+ # Images
327
+ ".png",
328
+ ".jpg",
329
+ ".jpeg",
330
+ ".gif",
331
+ ".bmp",
332
+ ".ico",
333
+ ".svg",
334
+ ".webp",
335
+ # Fonts
336
+ ".ttf",
337
+ ".otf",
338
+ ".woff",
339
+ ".woff2",
340
+ ".eot",
341
+ # Archives
342
+ ".zip",
343
+ ".tar",
344
+ ".gz",
345
+ ".bz2",
346
+ ".xz",
347
+ ".7z",
348
+ # Compiled / binary
349
+ ".so",
350
+ ".dylib",
351
+ ".dll",
352
+ ".exe",
353
+ ".o",
354
+ ".a",
355
+ ".whl",
356
+ ".egg",
357
+ # Media
358
+ ".mp3",
359
+ ".mp4",
360
+ ".wav",
361
+ ".avi",
362
+ ".mov",
363
+ ".flac",
364
+ ".ogg",
365
+ # Documents
366
+ ".pdf",
367
+ ".doc",
368
+ ".docx",
369
+ ".xls",
370
+ ".xlsx",
371
+ ".ppt",
372
+ ".pptx",
373
+ # Data
374
+ ".db",
375
+ ".sqlite",
376
+ ".sqlite3",
377
+ ".pickle",
378
+ ".pkl",
379
+ }
380
+ )
381
+
382
+ _SKIP_DIRS = frozenset(
383
+ {
384
+ "__pycache__",
385
+ "node_modules",
386
+ ".git",
387
+ ".venv",
388
+ "venv",
389
+ ".tox",
390
+ ".mypy_cache",
391
+ ".pytest_cache",
392
+ ".ruff_cache",
393
+ "dist",
394
+ "build",
395
+ }
396
+ )
397
+
398
+
399
+ def _walk_dir(directory: Path) -> list[Path]:
400
+ """Recursively yield non-hidden, non-binary files under *directory*."""
401
+ files: list[Path] = []
402
+ for entry in sorted(directory.iterdir()):
403
+ if entry.name.startswith("."):
404
+ continue
405
+ if entry.is_dir():
406
+ if entry.name in _SKIP_DIRS or entry.name.endswith(".egg-info"):
407
+ continue
408
+ files.extend(_walk_dir(entry))
409
+ elif entry.is_file():
410
+ if entry.suffix.lower() in _SKIP_SUFFIXES:
411
+ continue
412
+ files.append(entry)
413
+ return files
414
+
415
+
281
416
  def check_paths(
282
417
  paths: list[Path],
283
418
  *,
@@ -285,12 +420,21 @@ def check_paths(
285
420
  dangerous: dict[int, str] | None = None,
286
421
  ) -> int:
287
422
  """Check multiple files. Returns 0 if all clean, 1 if any have problems."""
423
+ resolved = _resolve_paths(paths)
424
+ if not resolved:
425
+ print("No files to check.")
426
+ return 0
427
+
288
428
  has_error = False
289
- for path in paths:
429
+ checked = 0
430
+ for path in resolved:
290
431
  problems = check_file(path, extra_ranges=extra_ranges, dangerous=dangerous)
432
+ checked += 1
291
433
  if problems:
292
434
  has_error = True
293
435
  print(f"\n{path} contains illegal characters:")
294
436
  for p in problems:
295
437
  print(f" {p}")
438
+ if not has_error:
439
+ print(f"All {checked} files passed.")
296
440
  return 1 if has_error else 0
apdev/release.sh CHANGED
@@ -203,7 +203,11 @@ step1_version_verification() {
203
203
  echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
204
204
 
205
205
  PYPROJECT_VERSION=$(grep -E '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
206
- INIT_VERSION=$(grep -E '^__version__ = ' src/${PACKAGE_NAME}/__init__.py | sed 's/__version__ = "\(.*\)"/\1/')
206
+ # Support both static (__version__ = "x.x.x") and dynamic (importlib.metadata) version patterns
207
+ INIT_VERSION=$(python3 -c "from ${PACKAGE_NAME} import __version__; print(__version__)" 2>/dev/null)
208
+ if [ -z "$INIT_VERSION" ]; then
209
+ INIT_VERSION=$(grep -E '^__version__ = ' src/${PACKAGE_NAME}/__init__.py | sed 's/__version__ = "\(.*\)"/\1/')
210
+ fi
207
211
 
208
212
  echo -e " pyproject.toml: ${CYAN}${PYPROJECT_VERSION}${NC}"
209
213
  echo -e " __init__.py: ${CYAN}${INIT_VERSION}${NC}"
@@ -211,6 +215,7 @@ step1_version_verification() {
211
215
 
212
216
  if [ "$PYPROJECT_VERSION" != "$VERSION" ] || [ "$INIT_VERSION" != "$VERSION" ]; then
213
217
  echo -e "${RED}❌ Version mismatch detected!${NC}"
218
+ echo -e "${YELLOW}💡 Hint: Try 'pip install -e .' to sync the installed package version${NC}"
214
219
  return 1
215
220
  fi
216
221
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apdev
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Shared development tools for Python projects - character validation, circular import detection, and more
5
5
  Author-email: aipartnerup <tercel.yi@gmail.com>
6
6
  License: Apache-2.0
@@ -8,6 +8,7 @@ Project-URL: Homepage, https://aipartnerup.com
8
8
  Project-URL: Documentation, https://github.com/aipartnerup/apdev
9
9
  Project-URL: Repository, https://github.com/aipartnerup/apdev
10
10
  Project-URL: Issues, https://github.com/aipartnerup/apdev/issues
11
+ Keywords: development-tools,quality-assurance,linting,static-analysis,character-validation,circular-imports,release-automation,unicode-checker,trojan-source-detection
11
12
  Classifier: Development Status :: 4 - Beta
12
13
  Classifier: Intended Audience :: Developers
13
14
  Classifier: License :: OSI Approved :: Apache Software License
@@ -29,7 +30,7 @@ Requires-Dist: ruff>=0.1.0; extra == "dev"
29
30
 
30
31
  # apdev (Python)
31
32
 
32
- Shared development tools for Python projects.
33
+ General-purpose development tools for Python projects.
33
34
 
34
35
  ## Installation
35
36
 
@@ -50,12 +51,25 @@ pip install apdev[dev]
50
51
  Validate that files contain only allowed characters (ASCII, common emoji, and technical symbols like arrows and box-drawing characters).
51
52
 
52
53
  ```bash
54
+ # Check default project directories (src/, tests/, examples/) and config files
55
+ apdev check-chars
56
+
57
+ # Check a directory recursively
58
+ apdev check-chars src/
59
+
53
60
  # Check specific files
54
61
  apdev check-chars src/mypackage/*.py
55
62
 
56
- # Use with pre-commit (see below)
63
+ # Enable extra charset (e.g. Chinese characters)
64
+ apdev check-chars --charset chinese src/
57
65
  ```
58
66
 
67
+ Options:
68
+
69
+ - `--charset <name>` — Enable a built-in charset preset (repeatable, e.g. `chinese`)
70
+ - `--charset-file <path>` — Load a custom charset JSON file (repeatable)
71
+ - Environment variable `APDEV_EXTRA_CHARS` — Comma-separated list of charset names or file paths, used when no `--charset`/`--charset-file` is given
72
+
59
73
  ### check-imports
60
74
 
61
75
  Detect circular imports in a Python package.
@@ -64,7 +78,7 @@ Detect circular imports in a Python package.
64
78
  # Specify package explicitly
65
79
  apdev check-imports --package mypackage --src-dir src
66
80
 
67
- # Or configure in pyproject.toml (see below)
81
+ # Or configure in pyproject.toml (see Configuration below)
68
82
  apdev check-imports
69
83
  ```
70
84
 
@@ -98,12 +112,19 @@ PROJECT_NAME=mypackage GITHUB_REPO=owner/repo apdev release
98
112
 
99
113
  ## Configuration
100
114
 
101
- Add to your project's `pyproject.toml`:
115
+ Add to your project's `pyproject.toml` so commands can run without CLI arguments:
102
116
 
103
117
  ```toml
104
118
  [tool.apdev]
105
- base_package = "mypackage"
106
- src_dir = "src"
119
+ base_package = "mypackage" # Required by check-imports
120
+ src_dir = "src" # Source directory (default: "src")
121
+ ```
122
+
123
+ With this config, both commands work out of the box:
124
+
125
+ ```bash
126
+ apdev check-chars # Checks default project directories and config files
127
+ apdev check-imports # Reads base_package / src_dir from pyproject.toml
107
128
  ```
108
129
 
109
130
  ## Pre-commit Integration
@@ -1,17 +1,17 @@
1
- apdev/__init__.py,sha256=9Bp1EfNWWBxDaD6FGTxvfGDfQgKypLXB3-P-pDlJTsk,83
1
+ apdev/__init__.py,sha256=pkWlshmklvJw13SH_RxmAGaZ7z87WcOYKQZV2MGOcJE,83
2
2
  apdev/__main__.py,sha256=Dzs_f6EHwKakFwroQl_ST3dQF5Ye4ANskJ21YFMNcVc,106
3
- apdev/check_chars.py,sha256=vyCbjfTTCzttrCAhLIxAwbs1Hkb5B5L5OYRfR-b6YHU,9464
3
+ apdev/check_chars.py,sha256=BJ6TIQ7pw5XyKQubAUwf_6ywtF0pAbvcTL08BZgOBjU,12600
4
4
  apdev/check_imports.py,sha256=IgwzP9tCLVfOyWCyc3rak-oAQpYrpOLtdgSQZMNTk0s,5596
5
5
  apdev/cli.py,sha256=Z9ktPfSC9LVoLgPPEHu2UE0qKAP2oHl3C5YdZn_ttY0,4647
6
6
  apdev/config.py,sha256=6EpHWbvgNea2Gms9U2ykjCVSk47mimWAJhqXrH6q6MQ,964
7
7
  apdev/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- apdev/release.sh,sha256=aD0zA13rp43aQBQTFENNWhnLJU1QkGU8-Z56Z78EKZg,34618
8
+ apdev/release.sh,sha256=Fb0q3fQOYnJD0UE6IBhjJ4QDYRDT8yzxhW--LDHoRAU,34974
9
9
  apdev/charsets/base.json,sha256=0DIilqz2W_ph5ILSwW86YdnIy_Vb80l1XcqaaCK_d2w,2460
10
10
  apdev/charsets/chinese.json,sha256=AU8V04QCdiNpbgxx6CBcndpJTgwfmkzc6T45h4GVt-M,366
11
11
  apdev/charsets/japanese.json,sha256=_LrreJ9nxL9zNcl1Kkzuez_0YdODXaYRu-Z4mj9_rL4,516
12
12
  apdev/charsets/korean.json,sha256=h3BMw0LiZSb7ST7JbqWT7AfTt8CHVSOqFEf1Eed9dGE,534
13
- apdev-0.2.0.dist-info/METADATA,sha256=nXvEib9ZYSEmv-z_ED4XPmLi4mRTYPblL2pjR_c1vgI,3512
14
- apdev-0.2.0.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
15
- apdev-0.2.0.dist-info/entry_points.txt,sha256=RfeS7VcSDYsLXCMtpb1tm_yaTKHiN0OBBQtl0PBzi-8,41
16
- apdev-0.2.0.dist-info/top_level.txt,sha256=3vnF6yGM6GmziwDo7Vl8HDPLRuq4Pds5gV1Ns5vzpEE,6
17
- apdev-0.2.0.dist-info/RECORD,,
13
+ apdev-0.2.2.dist-info/METADATA,sha256=vM5zMFtdo7Dk-e1wDeSM3K8CWcDrpdCKzvB9Ts-8bHw,4571
14
+ apdev-0.2.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
15
+ apdev-0.2.2.dist-info/entry_points.txt,sha256=RfeS7VcSDYsLXCMtpb1tm_yaTKHiN0OBBQtl0PBzi-8,41
16
+ apdev-0.2.2.dist-info/top_level.txt,sha256=3vnF6yGM6GmziwDo7Vl8HDPLRuq4Pds5gV1Ns5vzpEE,6
17
+ apdev-0.2.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (82.0.0)
2
+ Generator: setuptools (82.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5