Skip to content

Commit

Permalink
chore: fix deprecation warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Callahan Kovacs <[email protected]>
  • Loading branch information
mr-cal committed Oct 4, 2024
1 parent 5a42f0a commit 29c6d9d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion snapcraft/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def _register_default_plugins(self) -> None:

@override
def _configure_services(self, provider_name: str | None) -> None:
self.services.set_kwargs(
self.services.update_kwargs(
"package",
build_plan=self._build_plan,
snapcraft_yaml_path=self._snapcraft_yaml_path,
Expand Down
6 changes: 4 additions & 2 deletions snapcraft/commands/validation_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ def _submit_validation_set(
key_name: Optional[str],
store_client: StoreClientCLI,
) -> None:
emit.debug(f"Posting assertion to build: {edited_validation_sets.json()}")
emit.debug(
f"Posting assertion to build: {edited_validation_sets.model_dump_json()}"
)
build_assertion = store_client.post_validation_sets_build_assertion(
validation_sets=edited_validation_sets.marshal()
)
Expand All @@ -148,7 +150,7 @@ def _submit_validation_set(
response = store_client.post_validation_sets(
signed_validation_sets=signed_validation_sets
)
emit.debug(f"Response: {response.json()}")
emit.debug(f"Response: {response.model_dump_json()}")


def _generate_template(
Expand Down
2 changes: 1 addition & 1 deletion snapcraft/linters/linters.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def report(
issues_by_result.setdefault(issue.result, []).append(issue)

if json_output:
display(json.dumps([x.dict(exclude_none=True) for x in issues]))
display(json.dumps([x.model_dump(exclude_none=True) for x in issues]))
else:
# show issues by result
for result, header in _lint_reports.items():
Expand Down
6 changes: 3 additions & 3 deletions snapcraft_legacy/project/_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import datetime
import hashlib
import os
from datetime import datetime
from pathlib import Path
from typing import List, Set

Expand Down Expand Up @@ -67,7 +67,7 @@ def __init__(
self._work_dir = work_dir

self.local_plugins_dir = self._get_local_plugins_dir()
self._start_time = datetime.utcnow()
self._start_time = datetime.datetime.now(datetime.UTC)

# XXX: (Re)set by Config because it mangles source data.
# Ideally everywhere wold converge to operating on snap_meta, and ww
Expand Down Expand Up @@ -170,6 +170,6 @@ def _get_stage_packages_target_arch(self) -> str:
else:
return self.target_arch

def _get_start_time(self) -> datetime:
def _get_start_time(self) -> datetime.datetime:
"""Returns the timestamp for when a snapcraft project was loaded."""
return self._start_time
4 changes: 2 additions & 2 deletions tests/unit/linters/test_linters.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ def test_base_linter_is_file_ignored():

# The "test-path" Path must be ignored by the "main" filter and all categories.
assert linter.is_file_ignored(Path("test-path"))
assert linter.is_file_ignored(Path("test-path", category="test-1"))
assert linter.is_file_ignored(Path("test-path", category="test-2"))
assert linter.is_file_ignored(Path("test-path"), category="test-1")
assert linter.is_file_ignored(Path("test-path"), category="test-2")

# "test-1-path" is ignored by the "test-1" only
assert not linter.is_file_ignored(Path("test-1-path"))
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/services/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_metadata(
):
project_path = new_dir / "snapcraft.yaml"
snapcraft_yaml(filename=project_path)
default_factory.set_kwargs(
default_factory.update_kwargs(
"lifecycle",
work_dir=Path("work"),
cache_dir=new_dir,
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_write_metadata(
default_build_plan,
new_dir,
):
default_factory.set_kwargs(
default_factory.update_kwargs(
"lifecycle",
work_dir=Path("work"),
cache_dir=new_dir,
Expand Down Expand Up @@ -163,7 +163,7 @@ def test_write_metadata_with_manifest(
new_dir,
):
monkeypatch.setenv("SNAPCRAFT_BUILD_INFO", "1")
default_factory.set_kwargs(
default_factory.update_kwargs(
"lifecycle",
work_dir=Path("work"),
cache_dir=new_dir,
Expand All @@ -180,7 +180,7 @@ def test_write_metadata_with_manifest(
# This will be different every time due to started_at differing, we can check
# that it's a valid manifest and compare some fields to snap.yaml.
manifest_dict = yaml.safe_load((prime_dir / "snap" / "manifest.yaml").read_text())
manifest = models.Manifest.parse_obj(manifest_dict)
manifest = models.Manifest.model_validate(manifest_dict)

assert manifest.snapcraft_version == __version__
assert (
Expand Down Expand Up @@ -208,7 +208,7 @@ def test_write_metadata_with_project_hooks(
shutil.move(new_dir / "snap" / "snapcraft.yaml", new_dir)
shutil.rmtree(new_dir / "snap")

default_factory.set_kwargs(
default_factory.update_kwargs(
"lifecycle",
work_dir=work_dir,
cache_dir=new_dir,
Expand Down Expand Up @@ -257,7 +257,7 @@ def test_write_metadata_with_built_hooks(
new_dir,
):
work_dir = new_dir / "work"
default_factory.set_kwargs(
default_factory.update_kwargs(
"lifecycle",
work_dir=work_dir,
cache_dir=new_dir,
Expand Down Expand Up @@ -307,7 +307,7 @@ def test_write_metadata_with_project_gui(
new_dir,
):
work_dir = new_dir / "work"
default_factory.set_kwargs(
default_factory.update_kwargs(
"lifecycle",
work_dir=work_dir,
cache_dir=new_dir,
Expand Down Expand Up @@ -367,7 +367,7 @@ def test_update_project_parse_info(
):
work_dir = Path("work").resolve()

default_factory.set_kwargs(
default_factory.update_kwargs(
"lifecycle",
work_dir=work_dir,
cache_dir=new_dir,
Expand Down

0 comments on commit 29c6d9d

Please sign in to comment.