diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml deleted file mode 100644 index 0a92a9a4..00000000 --- a/.github/release-drafter.yml +++ /dev/null @@ -1,5 +0,0 @@ -# Config for https://github.com/apps/release-drafter -branches: - - main -template: | - $CHANGES diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 9694c450..5df77c99 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: '3.8' diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 1087792a..7a9d73b7 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -11,4 +11,6 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 - uses: pre-commit/action@v3.0.0 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e85f0a17..baf34ac8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,12 +10,16 @@ name: Publish jobs: publish: + environment: pypi + permissions: + contents: read + id-token: write runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: '3.8' @@ -28,7 +32,5 @@ jobs: --outdir dist/ . - name: Publish - if: startsWith(github.ref, 'refs/tags') + if: github.event.action == 'published' uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml deleted file mode 100644 index 4ddf5a2e..00000000 --- a/.github/workflows/release-drafter.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Release Drafter - -on: - push: - # branches to consider in the event; optional, defaults to all - branches: - - main - -jobs: - update_release_draft: - runs-on: ubuntu-latest - steps: - # Drafts your next Release notes as Pull Requests are merged into "main" - - uses: release-drafter/release-drafter@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9adfcbf6..bb0ff0fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: # NOTE: needed for pull_request_target to use PR code ref: ${{ github.event.pull_request.head.sha || github.ref }} - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.pyv }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dcdf8626..c94bd2e6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ repos: - id: black language_version: python3 repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.9.1 - hooks: - id: flake8 language_version: python3 diff --git a/docs/oauth.rst b/docs/oauth.rst index f52a70f7..b14d6ed4 100644 --- a/docs/oauth.rst +++ b/docs/oauth.rst @@ -176,7 +176,7 @@ Typically, service accounts are used in scenarios such as: - Running workloads which are not tied to the lifecycle of a human user. If we use OAuth client ID we need to do one manual login into the account with -`LocalWebserverAuth()`_. if we use a service account the login is automatic. +`LocalWebserverAuth()`_. If we use a service account the login is automatic. .. code-block:: python diff --git a/pydrive2/fs/spec.py b/pydrive2/fs/spec.py index c5abe03d..363e626d 100644 --- a/pydrive2/fs/spec.py +++ b/pydrive2/fs/spec.py @@ -256,13 +256,6 @@ def _ids_cache(self): } self._cache_path_id(self.base, cache["root_id"], cache=cache) - - for item in self._gdrive_list( - "'{}' in parents and trashed=false".format(cache["root_id"]) - ): - item_path = posixpath.join(self.base, item["title"]) - self._cache_path_id(item_path, item["id"], cache=cache) - return cache def _cache_path_id(self, path, *item_ids, cache=None): @@ -392,9 +385,7 @@ def _create_dir(self, parent_id, title, remote_path): return cached[0] item = self._gdrive_create_dir(parent_id, title) - - if parent_id == self._ids_cache["root_id"]: - self._cache_path_id(remote_path, item["id"]) + self._cache_path_id(remote_path, item["id"]) return item["id"] diff --git a/pydrive2/settings.py b/pydrive2/settings.py index 15ff567e..a7d12304 100644 --- a/pydrive2/settings.py +++ b/pydrive2/settings.py @@ -2,9 +2,9 @@ from yaml import YAMLError try: - from yaml import CLoader as Loader + from yaml import CSafeLoader as SafeLoader except ImportError: - from yaml import Loader + from yaml import SafeLoader SETTINGS_FILE = "settings.yaml" SETTINGS_STRUCT = { @@ -114,7 +114,7 @@ def LoadSettingsFile(filename=SETTINGS_FILE): """ try: with open(filename) as stream: - data = load(stream, Loader=Loader) + data = load(stream, Loader=SafeLoader) except (YAMLError, OSError) as e: raise SettingsError(e) return data diff --git a/setup.py b/setup.py index 978a371b..9e5e132b 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ "importlib_resources < 6; python_version < '3.10'", ] -tests_requirements.append("black==23.7.0") +tests_requirements.append("black==23.9.1") setup( name="PyDrive2",