diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..3b302bb --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ + +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + # Check for updates on Sunday, 8PM UTC + interval: "weekly" + day: "sunday" + time: "20:00" + + - package-ecosystem: "pip" + directory: "/" + schedule: + # Check for updates on Sunday, 8PM UTC + interval: "weekly" + day: "sunday" + time: "20:00" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba55b80..5879262 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,17 @@ on: branches: - main +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +defaults: + run: + shell: bash + +env: + FORCE_COLOR: "1" + jobs: pretest: name: Pre-test checks @@ -30,7 +41,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install tox + pip install -e .[dev] - name: Run pre-test checks run: | tox -e package @@ -40,8 +51,27 @@ jobs: needs: pretest strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12-dev"] - macOS-version: ["macos-11", "macos-12"] + python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev" ] + macOS-version: [ + # x86_64 runners + "macos-11", "macos-12", "macos-13", + # M1 runners + "macos-14" + ] + + include: + - experimental: false + - python-version: "3.13-dev" + experimental: true + + exclude: + # actions/setup-python doesn't provide Python3.8 or 3.9 for M1. + - macOS-version: "macos-14" + python-version: "3.8" + + - macOS-version: "macos-14" + python-version: "3.9" + runs-on: ${{ matrix.macOS-version }} steps: - uses: actions/checkout@v3.1.0 @@ -52,7 +82,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install --upgrade tox + pip install -e .[dev] - name: Test run: | tox -e py diff --git a/.github/workflows/pre-commit-update.yml b/.github/workflows/pre-commit-update.yml new file mode 100644 index 0000000..01854dd --- /dev/null +++ b/.github/workflows/pre-commit-update.yml @@ -0,0 +1,15 @@ +name: Update pre-commit + +on: + schedule: + - cron: "0 20 * * SUN" # Sunday @ 2000 UTC + workflow_dispatch: + +jobs: + pre-commit-update: + name: Update pre-commit + uses: beeware/.github/.github/workflows/pre-commit-update.yml@main + with: + create-changenote: false + secrets: + BRUTUS_PAT_TOKEN: ${{ secrets.BRUTUS_PAT_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 586ea3d..0db5167 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.5.0 hooks: - id: check-toml - id: check-yaml @@ -9,27 +9,25 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/PyCQA/isort - rev: 5.10.1 + rev: 5.13.2 hooks: - id: isort additional_dependencies: [toml] - repo: https://github.com/asottile/pyupgrade - rev: v3.2.0 + rev: v3.15.0 hooks: - id: pyupgrade - args: [--py37-plus] + args: [--py38-plus] - repo: https://github.com/myint/docformatter rev: v1.5.0 hooks: - id: docformatter args: [--in-place] - - repo: https://github.com/psf/black - rev: 22.10.0 + - repo: https://github.com/psf/black-pre-commit-mirror + rev: 24.1.1 hooks: - id: black - language_version: python3 - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 7.0.0 hooks: - id: flake8 - additional_dependencies: [flake8-eradicate==1.4.0] diff --git a/pyproject.toml b/pyproject.toml index 33f9aeb..2165305 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,77 @@ [build-system] -requires = ["setuptools>=60"] +requires = [ + "setuptools==69.0.0", +] build-backend = "setuptools.build_meta" +[project] +dynamic = ["version"] +name = "ds_store" +description = "Manipulate Finder .DS_Store files from Python" +readme = "README.rst" +requires-python = ">= 3.8" +license.text = "New BSD" +authors = [ + {name="Alastair Houghton", email="alastair@alastairs-place.net"} +] +maintainers = [ + {name="Russell Keith-Magee", email="russell@keith-magee.com"} +] +keywords = [ + "DS_Store" +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3 :: Only", + "Topic :: Desktop Environment", + "Topic :: Software Development :: Libraries :: Python Modules", +] +dependencies = [ + "mac_alias >= 2.0.1", +] + +[project.urls] +Homepage = "http://alastairs-place.net/projects/ds_store" +Source = "https://github.com/dmgbuild/ds_store" + +[project.scripts] +ds_store = "ds_store.__main__:main" + +[project.optional-dependencies] +dev = [ + "coverage == 7.4.1", + # Pre-commit 3.6.0 deprecated support for Python 3.8 + "pre-commit == 3.5.0 ; python_version < '3.9'", + "pre-commit == 3.6.0 ; python_version >= '3.9'", + "pytest == 8.0.0", + "pytest-cov == 4.1.0", + "tox == 4.12.1", +] +docs = [ + # Sphinx 7.2 deprecated support for Python 3.8 + "sphinx == 7.1.2 ; python_version < '3.9'", + "sphinx == 7.2.6 ; python_version >= '3.9'", + "sphinx-autobuild == 2021.3.14", + "sphinx_rtd_theme == 2.0.0" +] + +[tool.setuptools.dynamic] +version = {attr = "ds_store.__version__"} + [tool.isort] profile = "black" +split_on_trailing_comma = true +combine_as_imports = true skip_glob = [ "docs/conf.py", "venv*", "local", ] -multi_line_output = 3 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 0a39f51..0000000 --- a/setup.cfg +++ /dev/null @@ -1,73 +0,0 @@ -[metadata] -name = ds_store -version = attr: ds_store.__version__ -url = http://alastairs-place.net/projects/ds_store -project_urls = - Source = https://github.com/al45stair/ds_store -author = Alastair Houghton -author_email = alastair@alastairs-place.net -maintainer = Russell Keith-Magee -maintainer_email = russell@keith-magee.com -classifiers = - Development Status :: 5 - Production/Stable - License :: OSI Approved :: MIT License - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - Programming Language :: Python :: 3 :: Only - Topic :: Desktop Environment - Topic :: Software Development :: Libraries :: Python Modules -license = MIT License -license_files = - LICENSE -description = Manipulate Finder .DS_Store files from Python -long_description = file: README.rst -long_description_content_type = text/x-rst; charset=UTF-8 -keywords = - DS_Store -platforms = darwin - -[options] -zip_safe = False -packages = find: -python_requires = >= 3.7 -include_package_data = True -package_dir = - = src -install_requires = - mac_alias >= 2.0.1 - -[options.packages.find] -where = src - -[options.entry_points] -console_scripts = - ds_store = ds_store.__main__:main - -[options.extras_require] -dev = - pre-commit - tox -test = - pytest - pytest-tldr - pytest-cov -docs = - sphinx - sphinx-autobuild - sphinx_rtd_theme - -[flake8] -exclude=\ - */.eggs/*,\ - build/*,\ - docs/*,\ - .tox/*,\ - venv* -extend_ignore=C901,E203 -max-complexity = 25 -max-line-length = 119 diff --git a/src/ds_store/store.py b/src/ds_store/store.py index 58e9e1b..c22296a 100644 --- a/src/ds_store/store.py +++ b/src/ds_store/store.py @@ -65,7 +65,7 @@ class DSStoreEntry: """ def __init__(self, filename, code, typecode, value=None): - if str != bytes and type(filename) == bytes: + if str != bytes and isinstance(filename, bytes): filename = filename.decode("utf-8") if not isinstance(code, bytes): diff --git a/tox.ini b/tox.ini index bda1c9f..14b6a43 100644 --- a/tox.ini +++ b/tox.ini @@ -1,49 +1,49 @@ -# Tox (http://tox.testrun.org/) is a tool for running tests -# in multiple virtualenvs. This configuration file will run the -# test suite on all supported python versions. To use it, "pip install tox" -# and then run "tox" from this directory. +# flake8 doesn't believe in pyproject.toml, so we keep the configuration here. +[flake8] +exclude=\ + .eggs/*,\ + build/*,\ + docs/*,\ + .tox/*,\ + venv* +extend_ignore=C901,E203 +max-line-length = 119 [tox] -envlist = flake8,docs,package,py{37,38,39,310,311,312} +envlist = docs,package,py{38,39,310,311,312,313} skip_missing_interpreters = true isolated_build = True [testenv] extras = - test + dev commands = - pytest --cov -vv - coverage xml + python -m pytest --cov -vv -[testenv:flake8] -skip_install = True -deps = - flake8 -commands = flake8 {posargs} [testenv:docs] +build_dir = _build +change_dir = docs extras = docs +# -W: make warnings into errors +# --keep-going: continue on errors +# -j: run with multiple processes +# -n: nitpick mode +# -v: verbose logging +# -E: force rebuild of environment +# -T: print traceback on error +# -a: read/parse all files +# -d: use tox's temp dir for caching commands = - sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html + python -m sphinx build -W --keep-going -j auto -n -v -E -T -a -d _build/doctrees -b html . _build/html [testenv:package] skip-install = True +passenv = FORCE_COLOR deps = - check_manifest - build - twine + build==1.0.3 + twine==4.0.2 commands = - check-manifest -v python -m build --sdist --wheel --outdir dist/ . python -m twine check dist/* - -[testenv:publish] -deps = - wheel - twine -passenv = - TWINE_USERNAME - TWINE_PASSWORD -commands = - python -m twine upload dist/*