dependence 1.4.2__tar.gz → 1.4.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dependence
3
- Version: 1.4.2
3
+ Version: 1.4.3
4
4
  Summary: A dependency management tool for python projects
5
5
  Project-URL: Documentation, https://dependence.enorganic.org
6
6
  Project-URL: Repository, https://github.com/enorganic/dependence
@@ -550,6 +550,9 @@ def is_aliased(command: str) -> bool:
550
550
  try:
551
551
  shell_output: str = check_output( # noqa: S604
552
552
  (WHICH, command),
553
+ # This must run in the user's actual
554
+ # shell to detect shell aliases/functions; there is no
555
+ # non-shell equivalent for this check
553
556
  shell=True,
554
557
  )
555
558
  except CalledProcessError:
@@ -578,10 +581,14 @@ def _iter_pip_list() -> Iterable[tuple[str, PackageMetadata]]:
578
581
  )
579
582
  try:
580
583
  output = check_output(uv_command)
581
- except CalledProcessError:
582
- # `uv` was found on `PATH` but could not run (for example, a
583
- # CI security wrapper's shim with no real `uv` to delegate
584
- # to) -- fall back to this interpreter's own `pip`.
584
+ except (CalledProcessError, OSError):
585
+ # `uv` was found on `PATH` but could not run -- either it
586
+ # ran and exited non-zero (for example, a CI security
587
+ # wrapper's shim with no real `uv` to delegate to,
588
+ # `CalledProcessError`), or it could not be executed at
589
+ # all (a dangling shebang, a corrupted binary, or a
590
+ # permission error, `OSError`) -- fall back to this
591
+ # interpreter's own `pip`.
585
592
  output = check_output(pip_command)
586
593
  else:
587
594
  output = check_output(pip_command)
@@ -905,7 +912,7 @@ def is_editable(name: str) -> bool:
905
912
  """
906
913
  Return `True` if the indicated distribution is an editable installation.
907
914
  """
908
- return bool(normalize_name(name) in map_editable_project_locations())
915
+ return normalize_name(name) in map_editable_project_locations()
909
916
 
910
917
 
911
918
  def _get_setup_cfg_metadata(path: str, key: str) -> str:
@@ -1023,8 +1030,6 @@ def _setup_location(
1023
1030
  # If there is no setup.py file, we can't update egg info
1024
1031
  if not location.joinpath("setup.py").is_file():
1025
1032
  return
1026
- if isinstance(arguments, str):
1027
- arguments = (arguments,)
1028
1033
  current_directory: Path = Path(os.curdir).absolute()
1029
1034
  os.chdir(location)
1030
1035
  try:
@@ -1148,6 +1153,24 @@ def install_requirement(requirement: str | Requirement) -> None:
1148
1153
  return _install_requirement(requirement)
1149
1154
 
1150
1155
 
1156
+ def _raise_oserror(
1157
+ error: CalledProcessError | OSError,
1158
+ ) -> CalledProcessError:
1159
+ """
1160
+ Used by `_install_requirement_string` when there is no `uv`
1161
+ fallback to attempt (`uv` was absent from `PATH`, so `error` is
1162
+ this interpreter's own `pip` failing on its sole attempt): if
1163
+ `error` is an `OSError`, there is no `.output` to report via the
1164
+ caller's message construction, so re-raise it as-is. A
1165
+ `CalledProcessError` is exactly what `_install_requirement_string`
1166
+ already raised before its `uv` fallback existed, so it is returned
1167
+ unchanged for the caller to handle the same way as before.
1168
+ """
1169
+ if isinstance(error, OSError):
1170
+ raise error
1171
+ return error
1172
+
1173
+
1151
1174
  def _install_requirement_string(
1152
1175
  requirement_string: str,
1153
1176
  name: str = "",
@@ -1214,17 +1237,19 @@ def _install_requirement_string(
1214
1237
  )
1215
1238
  try:
1216
1239
  check_output(command, shell=shell)
1217
- except CalledProcessError as uv_error:
1218
- # Reassigned below if the `pip` fallback also fails, so the
1219
- # rest of this handler (including the bare re-raise) reports
1220
- # whichever command actually produced the *last* failure.
1221
- # Keep this as `except ... as uv_error` + assignment (not
1222
- # `except ... as error`) -- `error` is deliberately mutable.
1223
- error: CalledProcessError = uv_error
1240
+ except (CalledProcessError, OSError) as uv_error:
1241
+ # Reassigned below if `uv` was attempted and the `pip`
1242
+ # fallback also fails, so the rest of this handler (including
1243
+ # the bare re-raise) reports whichever command actually
1244
+ # produced the *last* failure.
1245
+ error: CalledProcessError
1224
1246
  if uv:
1225
- # `uv` was found on `PATH` but could not run (for example, a
1226
- # CI security wrapper's shim with no real `uv` to delegate
1227
- # to) -- fall back to this interpreter's own `pip`.
1247
+ # `uv` was found on `PATH` but failed -- either it ran and
1248
+ # exited non-zero (`CalledProcessError`, for example a CI
1249
+ # security wrapper's shim with no real `uv` to delegate
1250
+ # to) or it could not be executed at all (`OSError`: a
1251
+ # dangling shebang, a corrupted binary, or a permission
1252
+ # error) -- fall back to this interpreter's own `pip`.
1228
1253
  pip_command: tuple[str, ...] = (
1229
1254
  sys.executable,
1230
1255
  "-m",
@@ -1245,6 +1270,10 @@ def _install_requirement_string(
1245
1270
  error = pip_error
1246
1271
  else:
1247
1272
  return
1273
+ else:
1274
+ # No `uv` was attempted (`command` is already the `pip`
1275
+ # command) -- there is nothing to fall back to.
1276
+ error = _raise_oserror(uv_error)
1248
1277
  message: str = (
1249
1278
  (
1250
1279
  f"\nCould not install {name}:"
@@ -14,6 +14,7 @@ from typing import (
14
14
  IO,
15
15
  TYPE_CHECKING,
16
16
  Any,
17
+ cast,
17
18
  )
18
19
 
19
20
  import tomli
@@ -132,8 +133,9 @@ def _get_updated_requirement_string(
132
133
  pattern: str
133
134
  if ignore and any(fnmatch(name, pattern) for pattern in ignore):
134
135
  return requirement_string
136
+ distribution: Distribution | None = None
135
137
  try:
136
- distribution: Distribution = get_installed_distributions()[name]
138
+ distribution = get_installed_distributions()[name]
137
139
  if distribution.version is None:
138
140
  return requirement_string
139
141
  _update_requirement_specifiers(requirement, distribution.version)
@@ -432,32 +434,43 @@ def _update(
432
434
  ) -> None:
433
435
  message: str
434
436
  data: str
435
- update_function: Callable[[str], str]
437
+ # Each branch below assigns a function with a different keyword
438
+ # argument set (some accept `all_extra_name`/`include_pointers`/
439
+ # `exclude_pointers`, others don't), each paired with exactly the
440
+ # kwargs it accepts -- correct by construction, but not something
441
+ # the type checker can verify across a shared `**kwargs` dict, so
442
+ # each assignment is cast to the common `Callable[..., str]` shape
443
+ # rather than left to narrow back to its own literal signature.
444
+ update_function: Callable[..., str]
436
445
  kwargs: dict[str, str | Iterable[str]] = {}
437
446
  configuration_file_type: ConfigurationFileType = (
438
447
  get_configuration_file_type(path)
439
448
  )
440
449
  if configuration_file_type == ConfigurationFileType.SETUP_CFG:
441
- update_function = _get_updated_setup_cfg
450
+ update_function = cast("Callable[..., str]", _get_updated_setup_cfg)
442
451
  if all_extra_name:
443
452
  kwargs["all_extra_name"] = all_extra_name
444
453
  elif configuration_file_type == ConfigurationFileType.PYPROJECT_TOML:
445
- update_function = _get_updated_pyproject_toml
454
+ update_function = cast(
455
+ "Callable[..., str]", _get_updated_pyproject_toml
456
+ )
446
457
  kwargs.update(
447
458
  all_extra_name=all_extra_name,
448
459
  include_pointers=include_pointers,
449
460
  exclude_pointers=exclude_pointers,
450
461
  )
451
462
  elif configuration_file_type == ConfigurationFileType.TOML:
452
- update_function = _get_updated_toml
463
+ update_function = cast("Callable[..., str]", _get_updated_toml)
453
464
  kwargs.update(
454
465
  include_pointers=include_pointers,
455
466
  exclude_pointers=exclude_pointers,
456
467
  )
457
468
  elif configuration_file_type == ConfigurationFileType.TOX_INI:
458
- update_function = _get_updated_tox_ini
469
+ update_function = cast("Callable[..., str]", _get_updated_tox_ini)
459
470
  elif configuration_file_type == ConfigurationFileType.REQUIREMENTS_TXT:
460
- update_function = _get_updated_requirements_txt
471
+ update_function = cast(
472
+ "Callable[..., str]", _get_updated_requirements_txt
473
+ )
461
474
  else:
462
475
  message = f"Updating requirements for {path!s} is not supported"
463
476
  raise NotImplementedError(message)
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
 
7
7
  [project]
8
8
  name = "dependence"
9
- version = "1.4.2"
9
+ version = "1.4.3"
10
10
  description = "A dependency management tool for python projects"
11
11
  readme = "README.md"
12
12
  license = "MIT"
@@ -54,16 +54,12 @@ src = ""
54
54
  path = ".venv"
55
55
  python = "3.10"
56
56
  dependencies = [
57
- "mypy",
58
57
  "pytest",
59
58
  "ruff",
60
59
  ]
61
60
  pre-install-commands = [
62
61
  "uv pip install --upgrade pip setuptools",
63
62
  ]
64
- post-install-commands = [
65
- "hatch run mypy --install-types --non-interactive || echo",
66
- ]
67
63
 
68
64
  [tool.hatch.envs.docs]
69
65
  template = "docs"
@@ -81,7 +77,6 @@ skip-install = false
81
77
  template = "hatch-test"
82
78
  extra-dependencies = [
83
79
  "ruff",
84
- "mypy",
85
80
  "flake8",
86
81
  "tox",
87
82
  "black",
@@ -136,17 +131,17 @@ target-version = [
136
131
  "py313",
137
132
  ]
138
133
 
139
- [tool.mypy]
140
- python_version = "3.10"
141
- files = [
134
+ [tool.pyrefly]
135
+ project-includes = [
142
136
  "src",
143
137
  "tests",
144
138
  ]
145
- exclude = [
146
- "tests/test_projects",
139
+ project-excludes = [
140
+ "**/tests/test_projects*",
147
141
  ]
148
- disallow_untyped_defs = true
149
- disallow_incomplete_defs = true
142
+ python-version = "3.10.0"
143
+ check-unannotated-defs = true
144
+ infer-return-types = "never"
150
145
 
151
146
  [tool.coverage.run]
152
147
  include = [
File without changes
File without changes