fast-dev-cli 0.6.6__tar.gz → 0.7.1__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,23 +1,24 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fast-dev-cli
3
- Version: 0.6.6
3
+ Version: 0.7.1
4
4
  Summary:
5
5
  Author: Waket Zheng
6
6
  Author-email: waketzheng@gmail.com
7
- Requires-Python: >=3.11,<4.0
7
+ Requires-Python: >=3.10,<4.0
8
8
  Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.10
9
10
  Classifier: Programming Language :: Python :: 3.11
10
11
  Classifier: Programming Language :: Python :: 3.12
11
12
  Provides-Extra: all
12
- Requires-Dist: black (>=23.9.1) ; extra == "all"
13
13
  Requires-Dist: bumpversion (>=0.6.0,<0.7.0) ; extra == "all"
14
14
  Requires-Dist: click (>=7.1.1)
15
15
  Requires-Dist: coverage (>=6.5.0) ; extra == "all"
16
- Requires-Dist: isort (>=5.12.0) ; extra == "all"
17
- Requires-Dist: mypy (>=1.5.0) ; extra == "all"
18
- Requires-Dist: pytest (>=8.1.1,<9.0.0) ; extra == "all"
19
- Requires-Dist: ruff (>=0.3) ; extra == "all"
20
- Requires-Dist: typer (>=0.12.0) ; extra == "all"
16
+ Requires-Dist: mypy (>=1.10.0,<2.0.0) ; extra == "all"
17
+ Requires-Dist: pytest (>=8.2.0,<9.0.0) ; extra == "all"
18
+ Requires-Dist: ruff (>=0.4.2,<0.5.0) ; extra == "all"
19
+ Requires-Dist: strenum (>=0.4.15) ; python_version < "3.11"
20
+ Requires-Dist: type-extensions (>=0.1.2) ; python_version < "3.11"
21
+ Requires-Dist: typer (>=0.12.3,<0.13.0) ; extra == "all"
21
22
  Description-Content-Type: text/markdown
22
23
 
23
24
  <p align="center">
@@ -39,6 +40,12 @@ Description-Content-Type: text/markdown
39
40
  <a href="https://coveralls.io/github/waketzheng/fast-dev-cli?branch=main" target="_blank">
40
41
  <img src="https://coveralls.io/repos/github/waketzheng/fast-dev-cli/badge.svg?branch=main" alt="Coverage Status">
41
42
  </a>
43
+ <a href="https://github.com/astral-sh/ruff" target="_blank">
44
+ <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
45
+ </a>
46
+ <a href="https://github.com/python/mypy" target="_blank">
47
+ <img src="https://img.shields.io/badge/mypy-100%25-green.svg" alt="Mypy Coverage">
48
+ </a>
42
49
  </p>
43
50
 
44
51
  ---
@@ -17,6 +17,12 @@
17
17
  <a href="https://coveralls.io/github/waketzheng/fast-dev-cli?branch=main" target="_blank">
18
18
  <img src="https://coveralls.io/repos/github/waketzheng/fast-dev-cli/badge.svg?branch=main" alt="Coverage Status">
19
19
  </a>
20
+ <a href="https://github.com/astral-sh/ruff" target="_blank">
21
+ <img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
22
+ </a>
23
+ <a href="https://github.com/python/mypy" target="_blank">
24
+ <img src="https://img.shields.io/badge/mypy-100%25-green.svg" alt="Mypy Coverage">
25
+ </a>
20
26
  </p>
21
27
 
22
28
  ---
@@ -0,0 +1,31 @@
1
+ from .cli import (
2
+ __version__,
3
+ bump,
4
+ bump_version,
5
+ check,
6
+ lint,
7
+ make_style,
8
+ only_check,
9
+ sync,
10
+ tag,
11
+ test,
12
+ upgrade,
13
+ upload,
14
+ version,
15
+ )
16
+
17
+ __all__ = (
18
+ "__version__",
19
+ "version",
20
+ "bump_version",
21
+ "bump",
22
+ "lint",
23
+ "check",
24
+ "upload",
25
+ "test",
26
+ "sync",
27
+ "tag",
28
+ "upgrade",
29
+ "make_style",
30
+ "only_check",
31
+ )
@@ -3,11 +3,18 @@ import os
3
3
  import re
4
4
  import subprocess
5
5
  import sys
6
- from enum import StrEnum
7
6
  from functools import cached_property
8
7
  from pathlib import Path
9
8
  from subprocess import CompletedProcess
10
- from typing import Self, Type
9
+ from typing import Type
10
+
11
+ if sys.version_info >= (3, 11):
12
+ from enum import StrEnum
13
+ from typing import Self
14
+ else: # pragma: no cover
15
+ from strenum import StrEnum # type:ignore[no-redef,assignment]
16
+ from typing_extensions import Self
17
+
11
18
 
12
19
  __version__ = importlib.metadata.version(Path(__file__).parent.name)
13
20
 
@@ -246,7 +253,8 @@ class Project:
246
253
  def get_work_dir(
247
254
  cls: Type[Self], name=TOML_FILE, cwd: Path | None = None, allow_cwd=False
248
255
  ) -> Path:
249
- if d := cls.work_dir(name, cwd or Path.cwd(), cls.path_depth):
256
+ cwd = cwd or Path.cwd()
257
+ if d := cls.work_dir(name, cwd, cls.path_depth):
250
258
  return d
251
259
  if allow_cwd:
252
260
  return cls.get_root_dir(cwd)
@@ -379,8 +387,9 @@ class UpgradeDependencies(Project, DryRun):
379
387
  main_title = "[tool.poetry.dependencies]"
380
388
  text = toml_text.split(main_title)[-1]
381
389
  dev_flag = "--group dev"
382
- if (dev_title := cls.DevFlag.new.value) not in text:
383
- dev_title = cls.DevFlag.old.value # For poetry<=1.2
390
+ new_flag, old_flag = cls.DevFlag.new, cls.DevFlag.old
391
+ if (dev_title := getattr(new_flag, "value", new_flag)) not in text:
392
+ dev_title = getattr(old_flag, "value", old_flag) # For poetry<=1.2
384
393
  dev_flag = "--dev"
385
394
  others: list[list[str]] = []
386
395
  try:
@@ -422,7 +431,7 @@ class UpgradeDependencies(Project, DryRun):
422
431
  return _upgrade
423
432
 
424
433
  def gen(self: Self) -> str:
425
- return self.gen_cmd() + " && poetry update"
434
+ return self.gen_cmd() + " && poetry lock && poetry update"
426
435
 
427
436
 
428
437
  @cli.command()
@@ -487,36 +496,20 @@ class LintCode(DryRun):
487
496
 
488
497
  @staticmethod
489
498
  def check_lint_tool_installed() -> bool:
490
- return check_call("black --version")
499
+ return check_call("ruff --version")
491
500
 
492
501
  @classmethod
493
502
  def to_cmd(cls: Type[Self], paths=".", check_only=False) -> str:
494
503
  cmd = ""
495
- tools = ["isort --profile=black", "black", "ruff check --fix", "mypy"]
504
+ tools = ["ruff check --extend-select=I --fix", "ruff format", "mypy"]
496
505
  if check_only:
497
- tools[0] += " --check-only"
498
- tools[1] += " --check --fast"
506
+ tools[1] += " --check"
499
507
  if check_only or load_bool("NO_FIX"):
500
- tools[2] = tools[2].replace(" --fix", "")
508
+ tools[0] = tools[0].replace(" --fix", "")
501
509
  if load_bool("SKIP_MYPY"):
502
510
  # Sometimes mypy is too slow
503
511
  tools = tools[:-1]
504
512
  lint_them = " && ".join("{0}{%d} {1}" % i for i in range(2, len(tools) + 2))
505
- current_path = Path.cwd()
506
- root = Project.get_work_dir(cwd=current_path, allow_cwd=True)
507
- app_name = root.name.replace("-", "_")
508
- if (app_dir := root / app_name).exists() or (app_dir := root / "app").exists():
509
- if current_path == app_dir:
510
- tools[0] += " --src=."
511
- elif current_path == root:
512
- tools[0] += f" --src={app_dir.name}"
513
- else:
514
- parents = "../"
515
- for i, p in enumerate(current_path.parents):
516
- if p == root:
517
- parents *= i + 1
518
- break
519
- tools[0] += f" --src={parents}{app_dir.name}"
520
513
  prefix = "poetry run "
521
514
  if is_venv():
522
515
  if cls.check_lint_tool_installed():
@@ -550,7 +543,7 @@ def make_style(
550
543
  check_only: bool = Option(False, "--check-only", "-c"),
551
544
  dry: bool = Option(False, "--dry", help="Only print, not really run shell command"),
552
545
  ) -> None:
553
- """Run: isort+black+ruff to reformat code and then mypy to check"""
546
+ """Run: ruff check/format to reformat code and then mypy to check"""
554
547
  if isinstance(files, str):
555
548
  files = [files]
556
549
  if check_only:
@@ -611,12 +604,15 @@ def _should_run_test_script(path: Path) -> bool:
611
604
  @cli.command()
612
605
  def test(
613
606
  dry: bool = Option(False, "--dry", help="Only print, not really run shell command"),
607
+ ignore_script: bool = Option(False, "--ignore-script", "-i"),
614
608
  ) -> None:
615
609
  """Run unittest by pytest and report coverage"""
616
610
  cwd = Path.cwd()
617
611
  root = Project.get_work_dir(cwd=cwd, allow_cwd=True)
618
612
  test_script = root / "scripts" / "test.sh"
619
- if _should_run_test_script(test_script):
613
+ if not isinstance(ignore_script, bool):
614
+ ignore_script = getattr(ignore_script, "default", False)
615
+ if not ignore_script and _should_run_test_script(test_script):
620
616
  cmd = f"sh {test_script.relative_to(root)}"
621
617
  if cwd != root:
622
618
  cmd = f"cd {root} && " + cmd
@@ -0,0 +1,50 @@
1
+ [tool.poetry]
2
+ name = "fast-dev-cli"
3
+ version = "0.7.1"
4
+ description = ""
5
+ authors = ["Waket Zheng <waketzheng@gmail.com>"]
6
+ readme = "README.md"
7
+ packages = [{include = "fast_dev_cli"}]
8
+
9
+ [tool.poetry.dependencies]
10
+ python = "^3.10"
11
+ click = ">=7.1.1" # Many package depends on click, so only limit min version
12
+ strenum = {version = ">=0.4.15", python = "<3.11"}
13
+ type-extensions = {version = ">=0.1.2", python = "<3.11"}
14
+ coverage = {version = ">=6.5.0", optional = true}
15
+ ruff = {version = "^0.4.2", optional = true}
16
+ mypy = {version = "^1.10.0", optional = true}
17
+ bumpversion = {version = "^0.6.0", optional = true}
18
+ pytest = {version = "^8.2.0", optional = true}
19
+ typer = {version = "^0.12.3", optional = true}
20
+
21
+ [tool.poetry.extras]
22
+ all = ["ruff", "typer", "mypy", "bumpversion", "pytest", "coverage"]
23
+
24
+ [tool.poetry.group.dev.dependencies]
25
+ coveralls = {version = ">=4.0.0", python = ">=3.10,<3.13"}
26
+ coverage = ">=6.5.0" # use >= to compare with coveralls
27
+ typer = "^0.12.3"
28
+ ruff = "^0.4.2"
29
+ mypy = "^1.10.0"
30
+ pytest = "^8.2.0"
31
+ ipython = "^8.24.0"
32
+ bumpversion = "^0.6.0"
33
+ pytest-mock = "^3.14.0"
34
+ type-extensions = "^0.1.2"
35
+ strenum = "^0.4.15"
36
+
37
+ [build-system]
38
+ requires = ["poetry-core"]
39
+ build-backend = "poetry.core.masonry.api"
40
+
41
+ [tool.poetry.scripts]
42
+ fast = "fast_dev_cli:cli.cli"
43
+
44
+ [tool.mypy]
45
+ pretty = true
46
+ ignore_missing_imports = true
47
+ check_untyped_defs = true
48
+
49
+ [tool.ruff.lint.per-file-ignores]
50
+ "test_*.py" = ["E501"]
@@ -1,2 +0,0 @@
1
- from .cli import * # NOQA: F403
2
- from .cli import __version__ # NOQA: F401
@@ -1,57 +0,0 @@
1
- [tool.poetry]
2
- name = "fast-dev-cli"
3
- version = "0.6.6"
4
- description = ""
5
- authors = ["Waket Zheng <waketzheng@gmail.com>"]
6
- readme = "README.md"
7
- packages = [{include = "fast_dev_cli"}]
8
-
9
- [tool.poetry.dependencies]
10
- python = "^3.11"
11
- click = ">=7.1.1"
12
- isort = {version = ">=5.12.0", optional = true}
13
- black = {version = ">=23.9.1", optional = true}
14
- ruff = {version = ">=0.3", optional = true}
15
- mypy = {version = ">=1.5.0", optional = true}
16
- coverage = {version = ">=6.5.0", optional = true}
17
- bumpversion = {version = "^0.6.0", optional = true}
18
- pytest = {version = "^8.1.1", optional = true}
19
- typer = {version = ">=0.12.0", optional = true}
20
-
21
- [tool.poetry.extras]
22
- all = ["isort", "black", "ruff", "typer", "mypy", "bumpversion", "pytest", "coverage"]
23
-
24
- [tool.poetry.group.dev.dependencies]
25
- isort = "*"
26
- black = "*"
27
- ruff = ">=0.3"
28
- mypy = "*"
29
- pytest = "*"
30
- coverage = "*"
31
- bumpversion = "*"
32
- typer = {extras = ["all"], version = "*"}
33
- ipython = "^8.23.0"
34
- coveralls = "^3.3.1"
35
- pytest-mock = "^3.14.0"
36
-
37
- [build-system]
38
- requires = ["poetry-core"]
39
- build-backend = "poetry.core.masonry.api"
40
-
41
- [tool.poetry.scripts]
42
- fast = "fast_dev_cli:cli"
43
-
44
- [tool.isort]
45
- profile = "black"
46
-
47
- [tool.mypy]
48
- pretty = true
49
- ignore_missing_imports = true
50
- check_untyped_defs = true
51
-
52
- [[tool.mypy.overrides]]
53
- module = ["tests.*"]
54
- check_untyped_defs = false
55
-
56
- [tool.ruff.lint.per-file-ignores]
57
- "test_*.py" = ["E501"]
File without changes