Skip to content

Commit

Permalink
Merge pull request #740 from maresb/fix-deprecation-warnings
Browse files Browse the repository at this point in the history
Fix deprecation warnings
  • Loading branch information
maresb authored Nov 6, 2024
2 parents 1436bc1 + 831986b commit ca0a234
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
4 changes: 3 additions & 1 deletion conda_lock/conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,9 @@ def do_render(
"dev-dependencies": str(include_dev_dependencies).lower(),
"input-hash": lockfile.metadata.content_hash,
"version": distribution("conda_lock").version,
"timestamp": datetime.datetime.utcnow().strftime("%Y%m%dT%H%M%SZ"),
"timestamp": datetime.datetime.now(datetime.timezone.utc).strftime(
"%Y%m%dT%H%M%SZ"
),
}

filename = filename_template.format(**context)
Expand Down
4 changes: 2 additions & 2 deletions conda_lock/lockfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ def parse_conda_lock_file(path: pathlib.Path) -> Lockfile:
content = yaml.safe_load(f)
version = content.pop("version", None)
if version == 1:
lockfile = lockfile_v1_to_v2(LockfileV1.parse_obj(content))
lockfile = lockfile_v1_to_v2(LockfileV1.model_validate(content))
elif version == 2:
lockfile = Lockfile.parse_obj(content)
lockfile = Lockfile.model_validate(content)
elif version is None:
raise MissingLockfileVersion(f"{path} is missing a version")
else:
Expand Down
4 changes: 3 additions & 1 deletion conda_lock/lockfile/v1/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ class TimeMeta(StrictModel):
@classmethod
def create(cls) -> "TimeMeta":
return cls(
created_at=datetime.datetime.utcnow().isoformat(timespec="seconds") + "Z"
created_at=datetime.datetime.now(datetime.timezone.utc).strftime(
"%Y-%m-%dT%H:%M:%SZ"
)
)


Expand Down
6 changes: 2 additions & 4 deletions conda_lock/pypi_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,10 +437,8 @@ def _get_url(link: Link) -> str:

def _compute_hash(link: Link, lock_spec_hash: Optional[str]) -> HashModel:
if lock_spec_hash is None:
hashes: Dict[str, str] = {}
if link.hash_name is not None and link.hash is not None:
hashes[link.hash_name] = link.hash
return HashModel.parse_obj(hashes)
hashes: Dict[str, str] = dict(link.hashes)
return HashModel.model_validate(hashes)
else:
# A hash was provided in the lock spec, so that takes precedence
algo, value = lock_spec_hash.split(":")
Expand Down
2 changes: 1 addition & 1 deletion conda_lock/virtual_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def virtual_package_repo_from_specification(
data = yaml.safe_load(fp)
logging.debug("Virtual package spec: %s", data)

spec = VirtualPackageSpec.parse_obj(data)
spec = VirtualPackageSpec.model_validate(data)

repodata = _init_fake_repodata()
for subdir, subdir_spec in spec.subdirs.items():
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,8 @@ addopts = [
"--ignore-glob=**/vendor_poetry/**",
"--ignore-glob=**/_vendor/**"
]
log_level = "DEBUG"
testpaths = ["tests", "conda_lock"]
flake8-max-line-length = 105
flake8-ignore = ["docs/* ALL", "conda_lock/_version.py ALL"]
filterwarnings = "ignore::DeprecationWarning"

[tool.vendoring]
destination = "conda_lock/_vendor"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ def test_run_lock_with_time_metadata(
if is_micromamba(conda_exe):
monkeypatch.setenv("CONDA_FLAGS", "-v")
frozen_datetime = datetime.datetime(
year=1, month=7, day=12, hour=15, minute=6, second=3
year=1971, month=7, day=12, hour=15, minute=6, second=3
)
with freeze_time(frozen_datetime):
run_lock(
Expand Down

0 comments on commit ca0a234

Please sign in to comment.