diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be1c40e7..6c709b32 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,14 +14,14 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.6', '3.7', '3.8', '3.9', '3.10'] + python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11-dev'] steps: - uses: actions/checkout@v1 with: fetch-depth: 1 - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} diff --git a/artifactory.py b/artifactory.py index bfec2dd5..f12e6b33 100755 --- a/artifactory.py +++ b/artifactory.py @@ -640,7 +640,8 @@ def __iter__(self): return self.iterator -class _ArtifactoryAccessor(pathlib._Accessor): +class _ArtifactoryAccessor: + """ Implements operations with Artifactory REST API """ @@ -998,7 +999,7 @@ def unlink(self, pathobj): """ if not pathobj.exists(): - raise OSError(2, f"No such file or directory: {pathobj}") + raise FileNotFoundError(2, f"No such file or directory: {pathobj}") url = "/".join( [ @@ -1897,6 +1898,16 @@ def lchmod(self, mode): """ raise NotImplementedError() + def unlink(self, missing_ok=False): + """ + Removes a file or folder + """ + try: + self._accessor.unlink(self) + except FileNotFoundError: + if not missing_ok: + raise + def symlink_to(self, target, target_is_directory=False): """ Throw NotImplementedError diff --git a/setup.py b/setup.py index 37d18f4a..b748e24e 100755 --- a/setup.py +++ b/setup.py @@ -46,6 +46,7 @@ "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", "Topic :: Software Development :: Libraries", "Topic :: System :: Filesystems", ], diff --git a/tests/unit/test_artifactory_path.py b/tests/unit/test_artifactory_path.py index 6454f258..e8d5c69a 100644 --- a/tests/unit/test_artifactory_path.py +++ b/tests/unit/test_artifactory_path.py @@ -801,7 +801,7 @@ def test_unlink_raises_not_found(self): status=404, body="Unable to find item", ) - with self.assertRaises(OSError) as context: + with self.assertRaises(FileNotFoundError) as context: path.unlink() self.assertTrue("No such file or directory" in context.exception.strerror) diff --git a/tox.ini b/tox.ini index bb776255..224e13f4 100644 --- a/tox.ini +++ b/tox.ini @@ -5,6 +5,7 @@ envlist = py38 py39 py310 + py311 pre-commit [testenv]