dependence 1.2.7__py3-none-any.whl → 1.3.0__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.
dependence/update.py CHANGED
@@ -6,6 +6,7 @@ from collections import deque
6
6
  from configparser import ConfigParser, SectionProxy
7
7
  from copy import deepcopy
8
8
  from dataclasses import dataclass
9
+ from fnmatch import fnmatch
9
10
  from io import StringIO
10
11
  from itertools import chain
11
12
  from pathlib import Path
@@ -117,7 +118,7 @@ def _update_requirement_specifiers(
117
118
 
118
119
 
119
120
  def _get_updated_requirement_string(
120
- requirement_string: str, ignore: set[str]
121
+ requirement_string: str, ignore: Iterable[str]
121
122
  ) -> str:
122
123
  """
123
124
  This function updates version numbers in a requirement string to match
@@ -128,7 +129,8 @@ def _get_updated_requirement_string(
128
129
  return requirement_string
129
130
  requirement: Requirement = Requirement(requirement_string)
130
131
  name: str = normalize_name(requirement.name)
131
- if name in ignore:
132
+ pattern: str
133
+ if ignore and any(fnmatch(name, pattern) for pattern in ignore):
132
134
  return requirement_string
133
135
  try:
134
136
  distribution: Distribution = get_installed_distributions()[name]
@@ -147,15 +149,6 @@ def _get_updated_requirement_string(
147
149
  return str(requirement)
148
150
 
149
151
 
150
- def _normalize_ignore_argument(ignore: Iterable[str]) -> set[str]:
151
- ignore_set: set[str]
152
- # Normalize/harmonize excluded project names
153
- if isinstance(ignore, str):
154
- ignore = (ignore,)
155
- ignore_set = set(map(normalize_name, ignore))
156
- return ignore_set
157
-
158
-
159
152
  def _get_updated_requirements_txt(
160
153
  data: str, ignore: Iterable[str] = ()
161
154
  ) -> str:
@@ -169,10 +162,10 @@ def _get_updated_requirements_txt(
169
162
  - data (str): The contents of a *requirements.txt* file
170
163
  - ignore ([str]): One or more project names to leave as-is
171
164
  """
172
- ignore_set: set[str] = _normalize_ignore_argument(ignore)
165
+ ignore = (ignore,) if isinstance(ignore, str) else ignore
173
166
 
174
167
  def get_updated_requirement_string(requirement: str) -> str:
175
- return _get_updated_requirement_string(requirement, ignore=ignore_set)
168
+ return _get_updated_requirement_string(requirement, ignore=ignore)
176
169
 
177
170
  return "\n".join(map(get_updated_requirement_string, data.split("\n")))
178
171
 
@@ -188,14 +181,14 @@ def _get_updated_setup_cfg(
188
181
  Parameters:
189
182
 
190
183
  - data (str): The contents of a *setup.cfg* file
191
- - ignore ([str]): One or more project names to leave as-is
184
+ - ignore ([str]): One or more project names or patterns to leave as-is
192
185
  - all_extra_name (str): An (optional) extra name which will
193
186
  consolidate requirements from all other extras
194
187
  """
195
- ignore_set: set[str] = _normalize_ignore_argument(ignore)
188
+ ignore = (ignore,) if isinstance(ignore, str) else ignore
196
189
 
197
190
  def get_updated_requirement_string(requirement: str) -> str:
198
- return _get_updated_requirement_string(requirement, ignore=ignore_set)
191
+ return _get_updated_requirement_string(requirement, ignore=ignore)
199
192
 
200
193
  # Parse
201
194
  parser: ConfigParser = ConfigParser()
@@ -254,14 +247,14 @@ def _get_updated_tox_ini(data: str, ignore: Iterable[str] = ()) -> str:
254
247
  - data (str): The contents of a **tox.ini** file
255
248
  - ignore ([str]): One or more project names to leave as-is
256
249
  """
257
- ignore_set: set[str] = _normalize_ignore_argument(ignore)
250
+ ignore = (ignore,) if isinstance(ignore, str) else ignore
258
251
 
259
252
  def get_updated_requirement_string(requirement: str) -> str:
260
253
  prefix: str | None = None
261
254
  if ":" in requirement:
262
255
  prefix, requirement = requirement.split(":", maxsplit=1)
263
256
  requirement = _get_updated_requirement_string(
264
- requirement, ignore=ignore_set
257
+ requirement, ignore=ignore
265
258
  )
266
259
  if prefix is not None:
267
260
  requirement = f"{prefix}: {requirement.lstrip()}"
@@ -307,10 +300,10 @@ def _update_document_requirements(
307
300
  include_pointers: tuple[str, ...] = (),
308
301
  exclude_pointers: tuple[str, ...] = (),
309
302
  ) -> None:
310
- ignore_set: set[str] = _normalize_ignore_argument(ignore)
303
+ ignore = (ignore,) if isinstance(ignore, str) else ignore
311
304
 
312
305
  def get_updated_requirement_string(requirement: str) -> str:
313
- return _get_updated_requirement_string(requirement, ignore=ignore_set)
306
+ return _get_updated_requirement_string(requirement, ignore=ignore)
314
307
 
315
308
  # Find and update requirements
316
309
  requirements_list: list[str]
@@ -499,7 +492,7 @@ def update(
499
492
  Parameters:
500
493
  paths: One or more local paths to a pyproject.toml,
501
494
  setup.cfg, and/or requirements.txt files
502
- ignore: One or more project/package names to ignore (leave
495
+ ignore: One or more project/package names or patterns to ignore (leave
503
496
  as-is) when updating dependency requirement specifiers.
504
497
  all_extra_name: If provided, an extra which consolidates
505
498
  the requirements for all other extras will be added/updated to
@@ -544,8 +537,8 @@ def main() -> None:
544
537
  type=str,
545
538
  action="append",
546
539
  help=(
547
- "A comma-separated list of distributions to ignore (leave "
548
- "any requirements pertaining to the package as-is) "
540
+ "A comma-separated list of distributions or patterns to ignore "
541
+ "(leave any requirements pertaining to the package as-is) "
549
542
  ),
550
543
  )
551
544
  parser.add_argument(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dependence
3
- Version: 1.2.7
3
+ Version: 1.3.0
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
@@ -13,7 +13,7 @@ Requires-Dist: packaging
13
13
  Requires-Dist: pip
14
14
  Requires-Dist: setuptools>63
15
15
  Requires-Dist: tomli-w~=1.2
16
- Requires-Dist: tomli~=2.3
16
+ Requires-Dist: tomli~=2.4
17
17
  Description-Content-Type: text/markdown
18
18
 
19
19
  # dependence
@@ -3,9 +3,9 @@ dependence/__main__.py,sha256=gsluad-hgMvktrflSNLEMB3F-G_BKvlIGTHL0c1aQd8,1822
3
3
  dependence/_utilities.py,sha256=DqERa9O_RXEklq34y1rDrRXqWit9yz-W-WSG1KG4aWk,39120
4
4
  dependence/freeze.py,sha256=IAJr34cpLX5iYdCLa0E2P3IhuUKvif90SAW4ITghQpE,18990
5
5
  dependence/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- dependence/update.py,sha256=KGNj-COhRnbxGVAUikBKdUgJCz0xZ741Z6HEBny7diQ,20852
6
+ dependence/update.py,sha256=ZO2028Zc0Ad9T1yskdssff0HaoDC2M6SpPo7Nf0anVg,20694
7
7
  dependence/upgrade.py,sha256=nyOahgBJayeVeicM4AJ72lp2uDMvJOcCNUZIhVKk1do,7882
8
- dependence-1.2.7.dist-info/METADATA,sha256=jMnylfWZ3MbmC3xFdORWi3JbyPaAtYcNyh_Sj_xlyU4,8366
9
- dependence-1.2.7.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
10
- dependence-1.2.7.dist-info/entry_points.txt,sha256=NStO_B0D81ObVYr9zDs6LCy0whm0a8KCiiFHMmTwOVE,56
11
- dependence-1.2.7.dist-info/RECORD,,
8
+ dependence-1.3.0.dist-info/METADATA,sha256=82ujVPyAER5PIB7XTzIezMbCjq6zqCCZ9uMJh7Y48Ig,8366
9
+ dependence-1.3.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
10
+ dependence-1.3.0.dist-info/entry_points.txt,sha256=NStO_B0D81ObVYr9zDs6LCy0whm0a8KCiiFHMmTwOVE,56
11
+ dependence-1.3.0.dist-info/RECORD,,