fast-dev-cli 0.9.2__tar.gz → 0.9.4__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.
Files changed (27) hide show
  1. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/PKG-INFO +2 -2
  2. fast_dev_cli-0.9.4/fast_dev_cli/__init__.py +1 -0
  3. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/fast_dev_cli/cli.py +14 -8
  4. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/pyproject.toml +2 -2
  5. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/tests/test_lint.py +32 -0
  6. fast_dev_cli-0.9.4/tests/test_poetry_version_plugin.py +62 -0
  7. fast_dev_cli-0.9.2/fast_dev_cli/__init__.py +0 -1
  8. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/LICENSE +0 -0
  9. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/README.md +0 -0
  10. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/fast_dev_cli/__main__.py +0 -0
  11. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/fast_dev_cli/py.typed +0 -0
  12. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/pdm_build.py +0 -0
  13. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/scripts/check.sh +0 -0
  14. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/scripts/format.sh +0 -0
  15. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/scripts/test.sh +0 -0
  16. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/tests/__init__.py +0 -0
  17. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/tests/conftest.py +0 -0
  18. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/tests/test_bump.py +0 -0
  19. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/tests/test_fast_test.py +0 -0
  20. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/tests/test_functions.py +0 -0
  21. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/tests/test_runserver.py +0 -0
  22. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/tests/test_sync.py +0 -0
  23. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/tests/test_tag.py +0 -0
  24. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/tests/test_upgrade.py +0 -0
  25. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/tests/test_upload.py +0 -0
  26. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/tests/test_version.py +0 -0
  27. {fast_dev_cli-0.9.2 → fast_dev_cli-0.9.4}/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fast-dev-cli
3
- Version: 0.9.2
3
+ Version: 0.9.4
4
4
  Summary: Python project development tool.
5
5
  Author-Email: Waket Zheng <waketzheng@gmail.com>>
6
6
  Classifier: Development Status :: 4 - Beta
@@ -23,7 +23,7 @@ Requires-Python: <4,>=3.10
23
23
  Requires-Dist: typer<0.13,>=0.12.3
24
24
  Requires-Dist: tomli<3,>=2.0.1; python_version < "3.11"
25
25
  Requires-Dist: coverage<8,>=7.5.1
26
- Requires-Dist: ruff<0.6,>=0.4.4
26
+ Requires-Dist: ruff<0.7,>=0.4.4
27
27
  Requires-Dist: mypy<2,>=1.10.0
28
28
  Requires-Dist: bumpversion2<2,>=1.4.0
29
29
  Requires-Dist: pytest<9,>=8.2.0
@@ -0,0 +1 @@
1
+ __version__ = "0.9.4"
@@ -35,10 +35,6 @@ else: # pragma: no cover
35
35
  __str__ = str.__str__
36
36
 
37
37
 
38
- def parse_files(args: list[str] | tuple[str, ...]) -> list[str]:
39
- return [i for i in args if not i.startswith("-")]
40
-
41
-
42
38
  TOML_FILE = "pyproject.toml"
43
39
  cli = typer.Typer()
44
40
 
@@ -160,9 +156,13 @@ class BumpUp(DryRun):
160
156
  continue
161
157
  return line.split('path = "', 1)[-1].split('"')[0]
162
158
  context = tomllib.loads(toml_text)
163
- if (poetry_item := context["tool"]["poetry"])["version"] == "0":
159
+ try:
160
+ version_value = context["tool"]["poetry"]["version"]
161
+ except KeyError:
162
+ return TOML_FILE
163
+ if version_value == "0":
164
164
  try:
165
- package_item = poetry_item["packages"]
165
+ package_item = context["tool"]["poetry"]["packages"]
166
166
  except KeyError:
167
167
  packages = []
168
168
  else:
@@ -177,7 +177,7 @@ class BumpUp(DryRun):
177
177
  break
178
178
  else:
179
179
  raise ParseError("Version file not found! Where are you now?")
180
- return init_file.relative_to(cwd).as_posix()
180
+ return os.path.relpath(init_file, cwd)
181
181
 
182
182
  return TOML_FILE
183
183
 
@@ -557,6 +557,8 @@ class LintCode(DryRun):
557
557
  if load_bool("SKIP_MYPY"):
558
558
  # Sometimes mypy is too slow
559
559
  tools = tools[:-1]
560
+ elif load_bool("IGNORE_MISSING_IMPORTS"):
561
+ tools[-1] += " --ignore-missing-imports"
560
562
  lint_them = " && ".join("{0}{%d} {1}" % i for i in range(2, len(tools) + 2))
561
563
  prefix = ""
562
564
  should_run_by_tool = False
@@ -579,6 +581,10 @@ class LintCode(DryRun):
579
581
  return self.to_cmd(paths, self.check_only)
580
582
 
581
583
 
584
+ def parse_files(args: list[str] | tuple[str, ...]) -> list[str]:
585
+ return [i for i in args if not i.startswith("-")]
586
+
587
+
582
588
  def lint(files=None, dry=False) -> None:
583
589
  if files is None:
584
590
  files = parse_files(sys.argv[1:])
@@ -662,7 +668,7 @@ def test(dry: bool, ignore_script=False) -> None:
662
668
  root = Project.get_work_dir(cwd=cwd, allow_cwd=True)
663
669
  test_script = root / "scripts" / "test.sh"
664
670
  if not _ensure_bool(ignore_script) and _should_run_test_script(test_script):
665
- cmd = f"sh {test_script.relative_to(root)}"
671
+ cmd = f"sh {os.path.relpath(test_script, root)}"
666
672
  if cwd != root:
667
673
  cmd = f"cd {root} && " + cmd
668
674
  else:
@@ -34,12 +34,12 @@ dependencies = [
34
34
  "typer>=0.12.3,<0.13",
35
35
  "tomli>=2.0.1,<3; python_version < '3.11'",
36
36
  "coverage >=7.5.1,<8",
37
- "ruff >=0.4.4,<0.6",
37
+ "ruff >=0.4.4,<0.7",
38
38
  "mypy >=1.10.0,<2",
39
39
  "bumpversion2 >=1.4.0,<2",
40
40
  "pytest >=8.2.0,<9",
41
41
  ]
42
- version = "0.9.2"
42
+ version = "0.9.4"
43
43
 
44
44
  [project.urls]
45
45
  Homepage = "https://github.com/waketzheng/fast-dev-cli"
@@ -25,6 +25,21 @@ def mock_skip_mypy(monkeypatch):
25
25
  monkeypatch.setenv("SKIP_MYPY", "1")
26
26
 
27
27
 
28
+ @pytest.fixture
29
+ def mock_skip_mypy_0(monkeypatch):
30
+ monkeypatch.setenv("SKIP_MYPY", "0")
31
+
32
+
33
+ @pytest.fixture
34
+ def mock_ignore_missing_imports(monkeypatch):
35
+ monkeypatch.setenv("IGNORE_MISSING_IMPORTS", "1")
36
+
37
+
38
+ @pytest.fixture
39
+ def mock_ignore_missing_imports_0(monkeypatch):
40
+ monkeypatch.setenv("IGNORE_MISSING_IMPORTS", "0")
41
+
42
+
28
43
  SEP = " && "
29
44
  LINT_CMD = "ruff format . && ruff check --extend-select=I --fix . && mypy ."
30
45
  CHECK_CMD = "ruff format --check . && ruff check --extend-select=I . && mypy ."
@@ -112,6 +127,23 @@ def test_skip_mypy(mock_skip_mypy, mocker):
112
127
  assert LintCode(".").gen() == SEP.join(i for i in cmds if not i.startswith("mypy"))
113
128
 
114
129
 
130
+ def test_skip_mypy_0(mock_skip_mypy_0, mocker):
131
+ mocker.patch("fast_dev_cli.cli.is_venv", return_value=True)
132
+ assert LintCode(".").gen() == LINT_CMD
133
+
134
+
135
+ def test_ignore_missing_imports(mock_ignore_missing_imports, mocker):
136
+ mocker.patch("fast_dev_cli.cli.is_venv", return_value=True)
137
+ assert LintCode(".").gen() == LINT_CMD.replace(
138
+ "mypy ", "mypy --ignore-missing-imports "
139
+ )
140
+
141
+
142
+ def test_ignore_missing_imports_0(mock_ignore_missing_imports_0, mocker):
143
+ mocker.patch("fast_dev_cli.cli.is_venv", return_value=True)
144
+ assert LintCode(".").gen() == LINT_CMD
145
+
146
+
115
147
  def test_not_in_root(mocker):
116
148
  mocker.patch("fast_dev_cli.cli.is_venv", return_value=True)
117
149
  root = Path(__file__).parent.parent
@@ -0,0 +1,62 @@
1
+ from pathlib import Path
2
+
3
+ import pytest
4
+
5
+ from fast_dev_cli.cli import (
6
+ TOML_FILE,
7
+ BumpUp,
8
+ ParseError,
9
+ run_and_echo,
10
+ )
11
+
12
+ from .utils import chdir
13
+
14
+ CONF = """
15
+
16
+ [tool.poetry-version-plugin]
17
+ source = "init"
18
+ """
19
+
20
+
21
+ def test_version_plugin(tmp_path: Path) -> None:
22
+ package_path = tmp_path / "helloworld"
23
+ toml_file = package_path / TOML_FILE
24
+ init_file = package_path / package_path.name / "__init__.py"
25
+ a, b = 'version = "0.1.0"', 'version = "0"'
26
+ with chdir(tmp_path):
27
+ run_and_echo(f"poetry new {package_path.name}")
28
+ with chdir(package_path):
29
+ text = toml_file.read_text().replace(a, b)
30
+ toml_file.write_text(text + CONF)
31
+ init_file.write_text('__version__ = "0.0.1"\n')
32
+ assert (
33
+ BumpUp(part="patch", commit=False, dry=True).gen()
34
+ == 'bumpversion --parse "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)" --current-version="0.0.1" patch helloworld/__init__.py --allow-dirty'
35
+ )
36
+ run_and_echo("poetry run fast bump patch")
37
+ assert init_file.read_text() == '__version__ = "0.0.2"\n'
38
+ init_file.unlink()
39
+ with pytest.raises(ParseError, match=r"Version file not found!.*"):
40
+ BumpUp(part="patch", commit=False, dry=True).gen()
41
+
42
+
43
+ def test_version_plugin_include_defined(tmp_path: Path) -> None:
44
+ package_path = tmp_path / "hello world"
45
+ toml_file = package_path / TOML_FILE
46
+ package_name = package_path.name.replace(" ", "_")
47
+ init_file = package_path / package_name / "__init__.py"
48
+ a, b = 'version = "0.1.0"', 'version = "0"'
49
+ b += '\npackages = [{include = "%s"}]' % package_name
50
+ with chdir(tmp_path):
51
+ run_and_echo(f"poetry new '{package_path.name}'")
52
+ with chdir(package_path):
53
+ text = toml_file.read_text().replace(a, b)
54
+ toml_file.write_text(text + CONF)
55
+ run_and_echo(f"mv '{package_path.name}' {package_name}")
56
+ init_file.write_text('__version__ = "0.0.1"\n')
57
+ assert (
58
+ BumpUp(part="patch", commit=False, dry=True).gen()
59
+ == f'bumpversion --parse "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)" --current-version="0.0.1" patch {package_name}/__init__.py --allow-dirty'
60
+ )
61
+ run_and_echo("poetry run fast bump patch")
62
+ assert init_file.read_text() == '__version__ = "0.0.2"\n'
@@ -1 +0,0 @@
1
- __version__ = "0.9.2"
File without changes
File without changes
File without changes