diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1c95e3d8dd307abb21417e98468a4654b1484014..f972cd9cf2c0ab3a94442a9ae373962f75042954 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,19 +1,19 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 + rev: v4.3.0 hooks: - id: trailing-whitespace - id: check-json - id: check-yaml - - repo: https://gitlab.com/pycqa/flake8 - rev: 4.0.1 + - repo: https://github.com/pycqa/flake8 + rev: 5.0.4 hooks: - id: flake8 - additional_dependencies: [flake8-bugbear==22.3.23] + additional_dependencies: [flake8-bugbear==22.9.23] - repo: https://github.com/codespell-project/codespell - rev: v2.1.0 + rev: v2.2.2 hooks: - id: codespell name: Check source code spelling @@ -35,6 +35,6 @@ repos: - id: isort - repo: https://github.com/python/black - rev: 22.3.0 + rev: 22.10.0 hooks: - id: black diff --git a/PKG-INFO b/PKG-INFO index 4a1f9f165be2d1b97bc06b4ea9a0e47c999ef23b..0bffcf849391d681e7acd8b374f63e92b09fe374 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: swh.model -Version: 6.6.0 +Version: 6.6.1 Summary: Software Heritage data model Home-page: https://forge.softwareheritage.org/diffusion/DMOD/ Author: Software Heritage developers diff --git a/docs/persistent-identifiers.rst b/docs/persistent-identifiers.rst index 105f58c404fd68d6831efa28ab4e38b9321d9f6b..01da6aa1dc429a4bd468a61b00270ea6205ce4e6 100644 --- a/docs/persistent-identifiers.rst +++ b/docs/persistent-identifiers.rst @@ -296,7 +296,7 @@ Identifiers with qualifiers lines=9-15 * Here is an example of a :swh_web:`SWHID - <swh:1:cnt:f10371aa7b8ccabca8479196d6cd640676fd4a04;origin=https://github.com/web-platform-tests/wpt;visit=swh:1:snp:b37d435721bbd450624165f334724e3585346499;anchor=swh:1:rev:259d0612af038d14f2cd889a14a3adb6c9e96d96;path=/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/x%3Burl=foo/>` + <swh:1:cnt:f10371aa7b8ccabca8479196d6cd640676fd4a04;origin=https://github.com/web-platform-tests/wpt;visit=swh:1:snp:b37d435721bbd450624165f334724e3585346499;anchor=swh:1:rev:259d0612af038d14f2cd889a14a3adb6c9e96d96;path=/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/x%253Burl=foo/>` with a file path that requires percent-escaping:: swh:1:cnt:f10371aa7b8ccabca8479196d6cd640676fd4a04; @@ -376,13 +376,13 @@ programmatically resolve SWHIDs; see: :http:get:`/api/1/resolve/(swhid)/`. Examples: -* :swh_web:`<swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2>` -* :swh_web:`<swh:1:dir:d198bc9d7a6bcf6db04f476d29314f157507d505>` -* :swh_web:`<api/1/resolve/swh:1:rev:309cf2674ee7a0749978cf8265ab91a60aea0f7d>` -* :swh_web:`<api/1/resolve/swh:1:rel:22ece559cc7cc2364edc5e5593d63ae8bd229f9f>` -* :swh_web:`<api/1/resolve/swh:1:snp:c7c108084bc0bf3d81436bf980b46e98bd338453>` -* :swh_web:`<swh:1:cnt:4d99d2d18326621ccdd70f5ea66c2e2ac236ad8b;origin=https://gitorious.org/ocamlp3l/ocamlp3l_cvs.git;visit=swh:1:snp:d7f1b9eb7ccb596c2622c4780febaa02549830f9;anchor=swh:1:rev:2db189928c94d62a3b4757b3eec68f0a4d4113f0;path=/Examples/SimpleFarm/simplefarm.ml;lines=9-15>` -* :swh_web:`<wh:1:cnt:f10371aa7b8ccabca8479196d6cd640676fd4a04;origin=https://github.com/web-platform-tests/wpt;visit=swh:1:snp:b37d435721bbd450624165f334724e3585346499;anchor=swh:1:rev:259d0612af038d14f2cd889a14a3adb6c9e96d96;path=/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/x%3Burl=foo/>` +* :swh_web:`swh:1:cnt:94a9ed024d3859793618152ea559a168bbcbb5e2` +* :swh_web:`swh:1:dir:d198bc9d7a6bcf6db04f476d29314f157507d505` +* :swh_web:`api/1/resolve/swh:1:rev:309cf2674ee7a0749978cf8265ab91a60aea0f7d` +* :swh_web:`api/1/resolve/swh:1:rel:22ece559cc7cc2364edc5e5593d63ae8bd229f9f` +* :swh_web:`api/1/resolve/swh:1:snp:c7c108084bc0bf3d81436bf980b46e98bd338453` +* :swh_web:`swh:1:cnt:4d99d2d18326621ccdd70f5ea66c2e2ac236ad8b;origin=https://gitorious.org/ocamlp3l/ocamlp3l_cvs.git;visit=swh:1:snp:d7f1b9eb7ccb596c2622c4780febaa02549830f9;anchor=swh:1:rev:2db189928c94d62a3b4757b3eec68f0a4d4113f0;path=/Examples/SimpleFarm/simplefarm.ml;lines=9-15` +* :swh_web:`swh:1:cnt:f10371aa7b8ccabca8479196d6cd640676fd4a04;origin=https://github.com/web-platform-tests/wpt;visit=swh:1:snp:b37d435721bbd450624165f334724e3585346499;anchor=swh:1:rev:259d0612af038d14f2cd889a14a3adb6c9e96d96;path=/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/x%253Burl=foo/` Third-party resolvers @@ -408,7 +408,7 @@ Examples: * `<https://n2t.net/swh:1:rel:22ece559cc7cc2364edc5e5593d63ae8bd229f9f>`_ * `<https://n2t.net/swh:1:snp:c7c108084bc0bf3d81436bf980b46e98bd338453>`_ * `<https://n2t.net/swh:1:cnt:4d99d2d18326621ccdd70f5ea66c2e2ac236ad8b;origin=https://gitorious.org/ocamlp3l/ocamlp3l_cvs.git;visit=swh:1:snp:d7f1b9eb7ccb596c2622c4780febaa02549830f9;anchor=swh:1:rev:2db189928c94d62a3b4757b3eec68f0a4d4113f0;path=/Examples/SimpleFarm/simplefarm.ml;lines=9-15>`_ -* `<https://n2t.net/swh:1:cnt:f10371aa7b8ccabca8479196d6cd640676fd4a04;origin=https://github.com/web-platform-tests/wpt;visit=swh:1:snp:b37d435721bbd450624165f334724e3585346499;anchor=swh:1:rev:259d0612af038d14f2cd889a14a3adb6c9e96d96;path=/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/x%3Burl=foo/>`_ +* `<https://n2t.net/swh:1:cnt:f10371aa7b8ccabca8479196d6cd640676fd4a04;origin=https://github.com/web-platform-tests/wpt;visit=swh:1:snp:b37d435721bbd450624165f334724e3585346499;anchor=swh:1:rev:259d0612af038d14f2cd889a14a3adb6c9e96d96;path=/html/semantics/document-metadata/the-meta-element/pragma-directives/attr-meta-http-equiv-refresh/support/x%25253Burl=foo/>`_ References diff --git a/mypy.ini b/mypy.ini index e3daf6db7f7c4f0fe4c840400b0d18cb14a2e268..d411c51089c58ee654ae210c90af17e8bb388e1a 100644 --- a/mypy.ini +++ b/mypy.ini @@ -4,23 +4,3 @@ warn_unused_ignores = True # 3rd party libraries without stubs (yet) -[mypy-attrs_strict.*] # a bit sad, but... -ignore_missing_imports = True - -[mypy-deprecated.*] -ignore_missing_imports = True - -[mypy-django.*] # false positive, only used my hypotesis' extras -ignore_missing_imports = True - -[mypy-dulwich.*] -ignore_missing_imports = True - -[mypy-iso8601.*] -ignore_missing_imports = True - -[mypy-pkg_resources.*] -ignore_missing_imports = True - -[mypy-pytest.*] -ignore_missing_imports = True diff --git a/swh.model.egg-info/PKG-INFO b/swh.model.egg-info/PKG-INFO index 4a1f9f165be2d1b97bc06b4ea9a0e47c999ef23b..0bffcf849391d681e7acd8b374f63e92b09fe374 100644 --- a/swh.model.egg-info/PKG-INFO +++ b/swh.model.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: swh.model -Version: 6.6.0 +Version: 6.6.1 Summary: Software Heritage data model Home-page: https://forge.softwareheritage.org/diffusion/DMOD/ Author: Software Heritage developers diff --git a/swh/model/from_disk.py b/swh/model/from_disk.py index 8bd7f5d18f3bb39895969c8b260fd06d038391f6..058e77fa2b39e1293b404c91f1747049add5bfb6 100644 --- a/swh/model/from_disk.py +++ b/swh/model/from_disk.py @@ -149,7 +149,9 @@ class Content(MerkleLeaf): @classmethod def from_symlink(cls, *, path, mode): """Convert a symbolic link to a Software Heritage content entry""" - return cls.from_bytes(mode=mode, data=os.readlink(path)) + content = cls.from_bytes(mode=mode, data=os.readlink(path)) + content.data["path"] = path + return content @classmethod def from_file(cls, *, path, max_content_length=None): @@ -231,6 +233,7 @@ class Content(MerkleLeaf): data.pop("path", None) return model.SkippedContent.from_dict(data) elif "data" in data: + data.pop("path", None) return model.Content.from_dict(data) else: return DiskBackedContent.from_dict(data) diff --git a/swh/model/tests/test_from_disk.py b/swh/model/tests/test_from_disk.py index c07fef683b2c47583aa514dc0961331f63df1ef2..1ebcbbe981f8e53b73a2e3913bfd9b6b537c15ec 100644 --- a/swh/model/tests/test_from_disk.py +++ b/swh/model/tests/test_from_disk.py @@ -558,7 +558,9 @@ class SymlinkToContent(DataMixin, unittest.TestCase): path = os.path.join(self.tmpdir_name, filename) perms = 0o120000 conv_content = Content.from_symlink(path=path, mode=perms) - self.assertContentEqual(conv_content, symlink) + symlink_copy = symlink.copy() + symlink_copy["path"] = path + self.assertContentEqual(conv_content, symlink_copy, check_path=True) def test_symlink_to_base_model(self): for filename, symlink in self.symlinks.items(): diff --git a/tox.ini b/tox.ini index 5198d08ec4aa86f42e1cc9780dce3c6349bb8ef8..38261f49afac52c64a361662b2bdb4f40bd91ba4 100644 --- a/tox.ini +++ b/tox.ini @@ -24,15 +24,16 @@ commands = [testenv:black] skip_install = true deps = - black==22.3.0 + black==22.10.0 commands = {envpython} -m black --check swh [testenv:flake8] skip_install = true deps = - flake8==4.0.1 - flake8-bugbear==22.3.23 + flake8==5.0.4 + flake8-bugbear==22.9.23 + pycodestyle==2.9.1 commands = {envpython} -m flake8