fast-dev-cli 0.24.1__tar.gz → 0.24.3__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.
- {fast_dev_cli-0.24.1 → fast_dev_cli-0.24.3}/PKG-INFO +1 -1
- fast_dev_cli-0.24.3/fast_dev_cli/__init__.py +1 -0
- {fast_dev_cli-0.24.1 → fast_dev_cli-0.24.3}/fast_dev_cli/cli.py +42 -6
- {fast_dev_cli-0.24.1 → fast_dev_cli-0.24.3}/pyproject.toml +1 -1
- fast_dev_cli-0.24.1/fast_dev_cli/__init__.py +0 -1
- {fast_dev_cli-0.24.1 → fast_dev_cli-0.24.3}/LICENSE +0 -0
- {fast_dev_cli-0.24.1 → fast_dev_cli-0.24.3}/README.md +0 -0
- {fast_dev_cli-0.24.1 → fast_dev_cli-0.24.3}/fast_dev_cli/__main__.py +0 -0
- {fast_dev_cli-0.24.1 → fast_dev_cli-0.24.3}/fast_dev_cli/py.typed +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.24.3"
|
|
@@ -111,14 +111,15 @@ def yellow_warn(msg: str) -> None:
|
|
|
111
111
|
secho(msg, fg="yellow")
|
|
112
112
|
|
|
113
113
|
|
|
114
|
-
def load_bool(name: str, default: bool = False) -> bool:
|
|
114
|
+
def load_bool(name: str, default: bool = False, *, verbose: bool = True) -> bool:
|
|
115
115
|
if not (v := os.getenv(name)):
|
|
116
116
|
return default
|
|
117
117
|
if (lower := v.lower()) in ("0", "false", "f", "off", "no", "n"):
|
|
118
118
|
return False
|
|
119
119
|
elif lower in ("1", "true", "t", "on", "yes", "y"):
|
|
120
120
|
return True
|
|
121
|
-
|
|
121
|
+
if verbose:
|
|
122
|
+
secho(f"WARNING: can not convert value({v!r}) of {name} to bool!")
|
|
122
123
|
return default
|
|
123
124
|
|
|
124
125
|
|
|
@@ -1228,6 +1229,15 @@ class LintCode(DryRun):
|
|
|
1228
1229
|
prefix = ""
|
|
1229
1230
|
should_run_by_tool = with_prefix
|
|
1230
1231
|
requires_mypy = any(tool.startswith("mypy") for tool in tools)
|
|
1232
|
+
global_mypy = False
|
|
1233
|
+
if requires_mypy and Path.home().joinpath(".local/bin/mypy").exists():
|
|
1234
|
+
global_mypy = True
|
|
1235
|
+
mypy_opt = "--python-executable=.venv/bin/python"
|
|
1236
|
+
for i, t in enumerate(tools):
|
|
1237
|
+
if t.startswith("mypy"):
|
|
1238
|
+
if mypy_opt not in t:
|
|
1239
|
+
tools[i] = t + " " + mypy_opt
|
|
1240
|
+
break
|
|
1231
1241
|
if requires_mypy and not should_run_by_tool:
|
|
1232
1242
|
if is_venv() and Path(sys.argv[0]).parent != Path.home().joinpath(
|
|
1233
1243
|
".local/bin"
|
|
@@ -1244,6 +1254,8 @@ class LintCode(DryRun):
|
|
|
1244
1254
|
"You may need to run the following command"
|
|
1245
1255
|
f" to install ruff:\n\n {command}\n"
|
|
1246
1256
|
)
|
|
1257
|
+
elif global_mypy:
|
|
1258
|
+
should_run_by_tool = True
|
|
1247
1259
|
elif cls.missing_mypy_exec():
|
|
1248
1260
|
should_run_by_tool = True
|
|
1249
1261
|
if check_call('python -c "import fast_dev_cli"'):
|
|
@@ -1279,7 +1291,11 @@ class LintCode(DryRun):
|
|
|
1279
1291
|
tool
|
|
1280
1292
|
# `ruff <command>` get the same result with `pdm run ruff <command>`.
|
|
1281
1293
|
# Other tools should run inside the selected environment.
|
|
1282
|
-
if
|
|
1294
|
+
if (
|
|
1295
|
+
ruff_exists
|
|
1296
|
+
and tool.startswith("ruff")
|
|
1297
|
+
or (global_mypy and tool.startswith("mypy"))
|
|
1298
|
+
)
|
|
1283
1299
|
else prefix + tool
|
|
1284
1300
|
)
|
|
1285
1301
|
+ f" {paths}"
|
|
@@ -1581,19 +1597,39 @@ def upload(
|
|
|
1581
1597
|
|
|
1582
1598
|
|
|
1583
1599
|
def should_use_just() -> bool:
|
|
1584
|
-
if shutil.which("just") is None:
|
|
1600
|
+
if shutil.which("just") is None or load_bool("FASTDEVCLI_IGNORE_JUST_DEV"):
|
|
1585
1601
|
return False
|
|
1586
1602
|
d = Path.cwd()
|
|
1587
1603
|
for _ in range(5):
|
|
1588
1604
|
f = d / "justfile"
|
|
1589
1605
|
if f.exists():
|
|
1590
|
-
|
|
1591
|
-
return any(i.startswith("dev *args:") for i in text.splitlines())
|
|
1606
|
+
return _prefer_just_dev(f)
|
|
1592
1607
|
if d.joinpath("pyproject.toml").exists():
|
|
1593
1608
|
break
|
|
1594
1609
|
return False
|
|
1595
1610
|
|
|
1596
1611
|
|
|
1612
|
+
def _prefer_just_dev(f: Path) -> bool:
|
|
1613
|
+
text = f.read_text(encoding="utf-8")
|
|
1614
|
+
lines = text.splitlines()
|
|
1615
|
+
dev_recipe = "dev *args:"
|
|
1616
|
+
re_import = re.compile(r"import[?]? ")
|
|
1617
|
+
has_import = False
|
|
1618
|
+
for i, line in enumerate(lines):
|
|
1619
|
+
if line.startswith(dev_recipe):
|
|
1620
|
+
# Avoid cycle callback
|
|
1621
|
+
return "fast dev" not in lines[i + 1]
|
|
1622
|
+
elif not has_import and re_import.match(line):
|
|
1623
|
+
has_import = True
|
|
1624
|
+
if has_import:
|
|
1625
|
+
recipes = capture_cmd_output("just --list").splitlines()
|
|
1626
|
+
for recipe in recipes:
|
|
1627
|
+
recipe = recipe.strip()
|
|
1628
|
+
if recipe.startswith(dev_recipe):
|
|
1629
|
+
return "fast dev" not in recipe
|
|
1630
|
+
return False
|
|
1631
|
+
|
|
1632
|
+
|
|
1597
1633
|
def _parse_serve_file(uvicorn, filename: str, cmd: str, args: list) -> str:
|
|
1598
1634
|
if m := re.search(r"(.*):(\d+)$", filename):
|
|
1599
1635
|
h, p = m.group(1), m.group(2)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.24.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|