diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0895dbf..5b18374 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,13 +30,13 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} allow-prereleases: true @@ -58,7 +58,7 @@ jobs: - name: HTML coverage reports if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v6 with: - name: coverage_${{ matrix.python-version }} + name: coverage_${{ matrix.os }}-${{ matrix.python-version }} path: coverage diff --git a/.gitignore b/.gitignore index 878abdd..3e9007d 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,5 @@ wheels/ *.egg-info/ .installed.cfg *.egg -docs/ \ No newline at end of file +docs/ +.venv/ diff --git a/.travis.yml b/.travis.yml index 5cd6e5a..0a10e35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,21 @@ language: python -dist: xenial +dist: focal jobs: include: - - python: 2.7 - env: TOXENV=py27 - - python: 3.5 - env: TOXENV=py35 - - python: 3.6 - env: TOXENV=py36 - - python: 3.7 - env: TOXENV=py37 - - python: 3.8 - env: TOXENV=py3 - - python: 3.9 + - python: "3.8" + env: TOXENV=py38 + - python: "3.9" env: TOXENV=py39 - - python: 3.10 + - python: "3.10" env: TOXENV=py310 + - python: "3.11" + env: TOXENV=py311 + - python: "3.12" + env: TOXENV=py312 + - python: "3.13" + env: TOXENV=py313 - env: TOXENV=lint install: diff --git a/examples/buffer.py b/examples/buffer.py index 369ad26..6d349ee 100644 --- a/examples/buffer.py +++ b/examples/buffer.py @@ -1,8 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from __future__ import absolute_import - import filetype diff --git a/examples/bytes.py b/examples/bytes.py index e1b406c..90d9ef3 100644 --- a/examples/bytes.py +++ b/examples/bytes.py @@ -1,8 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from __future__ import absolute_import - import filetype diff --git a/examples/file.py b/examples/file.py index c9f4601..dc06947 100644 --- a/examples/file.py +++ b/examples/file.py @@ -1,8 +1,6 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from __future__ import absolute_import - import filetype diff --git a/filetype/__init__.py b/filetype/__init__.py index 3d0610e..eee7608 100644 --- a/filetype/__init__.py +++ b/filetype/__init__.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - from .filetype import * # noqa from .helpers import * # noqa from .match import * # noqa diff --git a/filetype/filetype.py b/filetype/filetype.py index cc374ad..543f759 100644 --- a/filetype/filetype.py +++ b/filetype/filetype.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - from .match import match from .types import TYPES, Type diff --git a/filetype/helpers.py b/filetype/helpers.py index afe4e68..332ad58 100644 --- a/filetype/helpers.py +++ b/filetype/helpers.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import from .types import TYPES from .match import ( image_match, font_match, document_match, diff --git a/filetype/match.py b/filetype/match.py index 8b6f11b..1f5e993 100644 --- a/filetype/match.py +++ b/filetype/match.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - from .types import ARCHIVE as archive_matchers from .types import AUDIO as audio_matchers from .types import APPLICATION as application_matchers diff --git a/filetype/types/__init__.py b/filetype/types/__init__.py index e833ab4..2137446 100644 --- a/filetype/types/__init__.py +++ b/filetype/types/__init__.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - from . import archive from . import audio from . import application diff --git a/filetype/types/application.py b/filetype/types/application.py index 6f02370..2b6de0d 100644 --- a/filetype/types/application.py +++ b/filetype/types/application.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - from .base import Type diff --git a/filetype/types/archive.py b/filetype/types/archive.py index 0ffc954..8f5b272 100644 --- a/filetype/types/archive.py +++ b/filetype/types/archive.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - import struct from .base import Type diff --git a/filetype/types/audio.py b/filetype/types/audio.py index 429d805..ee0a673 100644 --- a/filetype/types/audio.py +++ b/filetype/types/audio.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - from .base import Type diff --git a/filetype/types/base.py b/filetype/types/base.py index 7c0c0d2..53218dd 100644 --- a/filetype/types/base.py +++ b/filetype/types/base.py @@ -1,29 +1,29 @@ # -*- coding: utf-8 -*- -class Type(object): +class Type: """ Represents the file type object inherited by specific file type matchers. Provides convenient accessor and helper methods. """ - def __init__(self, mime, extension): + def __init__(self, mime: str, extension: str): self.__mime = mime self.__extension = extension @property - def mime(self): + def mime(self) -> str: return self.__mime @property - def extension(self): + def extension(self) -> str: return self.__extension - def is_extension(self, extension): + def is_extension(self, extension: str) -> bool: return self.__extension is extension - def is_mime(self, mime): + def is_mime(self, mime: str) -> bool: return self.__mime is mime - def match(self, buf): + def match(self, buf: bytes) -> bool: raise NotImplementedError diff --git a/filetype/types/document.py b/filetype/types/document.py index e523673..36c8a21 100644 --- a/filetype/types/document.py +++ b/filetype/types/document.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - from .base import Type diff --git a/filetype/types/font.py b/filetype/types/font.py index 461f5c4..9e6c6ed 100644 --- a/filetype/types/font.py +++ b/filetype/types/font.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - from .base import Type diff --git a/filetype/types/image.py b/filetype/types/image.py index 07db235..6dad591 100644 --- a/filetype/types/image.py +++ b/filetype/types/image.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - from .base import Type from .isobmff import IsoBmff diff --git a/filetype/types/isobmff.py b/filetype/types/isobmff.py index 2ac0ffe..e69a646 100644 --- a/filetype/types/isobmff.py +++ b/filetype/types/isobmff.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import + import codecs from .base import Type diff --git a/filetype/types/video.py b/filetype/types/video.py index 12672ed..ca11a87 100644 --- a/filetype/types/video.py +++ b/filetype/types/video.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - from .base import Type from .isobmff import IsoBmff diff --git a/filetype/utils.py b/filetype/utils.py index c954876..a6d0db8 100644 --- a/filetype/utils.py +++ b/filetype/utils.py @@ -1,11 +1,6 @@ # -*- coding: utf-8 -*- -# Python 2.7 workaround -try: - import pathlib -except ImportError: - pass - +import pathlib _NUM_SIGNATURE_BYTES = 8192 diff --git a/setup.py b/setup.py index 2236b93..17e4029 100644 --- a/setup.py +++ b/setup.py @@ -28,16 +28,16 @@ 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - '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.13', 'Topic :: System', 'Topic :: System :: Filesystems', 'Topic :: Utilities'], + python_requires='>=3.8', platforms=['any'], packages=find_packages(exclude=['dist', 'build', 'docs', 'tests', 'examples']), diff --git a/tests/test_benchmark.py b/tests/test_benchmark.py index 0992ed3..231c0c7 100644 --- a/tests/test_benchmark.py +++ b/tests/test_benchmark.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - import os import filetype diff --git a/tests/test_filetype.py b/tests/test_filetype.py index 68bc2c1..161cea5 100644 --- a/tests/test_filetype.py +++ b/tests/test_filetype.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - import os import unittest diff --git a/tests/test_types.py b/tests/test_types.py index 5154cf1..75f1ca7 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -from __future__ import absolute_import - import os import unittest diff --git a/tox.ini b/tox.ini index 108a516..0f60650 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ # and then run "tox" from this directory. [tox] -envlist = py27, py3{8,9,10,11,12,13}, lint, test, doc, clean +envlist = py3{8,9,10,11,12,13}, lint, test, doc, clean skip_missing_interpreters = true [testenv:test]