diff --git a/conda_lock/conda_lock.py b/conda_lock/conda_lock.py index e7b0689d3..d8bd1350e 100644 --- a/conda_lock/conda_lock.py +++ b/conda_lock/conda_lock.py @@ -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) diff --git a/conda_lock/lockfile/__init__.py b/conda_lock/lockfile/__init__.py index 92c0cddef..edf0a2bb3 100644 --- a/conda_lock/lockfile/__init__.py +++ b/conda_lock/lockfile/__init__.py @@ -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: diff --git a/conda_lock/lockfile/v1/models.py b/conda_lock/lockfile/v1/models.py index 05706f171..919ea5944 100644 --- a/conda_lock/lockfile/v1/models.py +++ b/conda_lock/lockfile/v1/models.py @@ -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" + ) ) diff --git a/conda_lock/pypi_solver.py b/conda_lock/pypi_solver.py index 444ae0650..4c3ebed44 100644 --- a/conda_lock/pypi_solver.py +++ b/conda_lock/pypi_solver.py @@ -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(":") diff --git a/conda_lock/virtual_package.py b/conda_lock/virtual_package.py index 7f372da8b..4732e3a01 100644 --- a/conda_lock/virtual_package.py +++ b/conda_lock/virtual_package.py @@ -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(): diff --git a/pyproject.toml b/pyproject.toml index cbd8b9467..b515f09b8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/tests/test_conda_lock.py b/tests/test_conda_lock.py index 92e7ec7da..6f32ac3bf 100644 --- a/tests/test_conda_lock.py +++ b/tests/test_conda_lock.py @@ -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(