Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ wheels/
*.egg-info/
.installed.cfg
*.egg
docs/
docs/
.venv/
24 changes: 11 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 0 additions & 2 deletions examples/buffer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

import filetype


Expand Down
2 changes: 0 additions & 2 deletions examples/bytes.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

import filetype


Expand Down
2 changes: 0 additions & 2 deletions examples/file.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import

import filetype


Expand Down
2 changes: 0 additions & 2 deletions filetype/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from .filetype import * # noqa
from .helpers import * # noqa
from .match import * # noqa
Expand Down
2 changes: 0 additions & 2 deletions filetype/filetype.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from .match import match
from .types import TYPES, Type

Expand Down
1 change: 0 additions & 1 deletion filetype/helpers.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 0 additions & 2 deletions filetype/match.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions filetype/types/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from . import archive
from . import audio
from . import application
Expand Down
2 changes: 0 additions & 2 deletions filetype/types/application.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from .base import Type


Expand Down
2 changes: 0 additions & 2 deletions filetype/types/archive.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import

import struct

from .base import Type
Expand Down
2 changes: 0 additions & 2 deletions filetype/types/audio.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from .base import Type


Expand Down
14 changes: 7 additions & 7 deletions filetype/types/base.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions filetype/types/document.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from .base import Type


Expand Down
2 changes: 0 additions & 2 deletions filetype/types/font.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from .base import Type


Expand Down
2 changes: 0 additions & 2 deletions filetype/types/image.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from .base import Type
from .isobmff import IsoBmff

Expand Down
2 changes: 1 addition & 1 deletion filetype/types/isobmff.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import

import codecs

from .base import Type
Expand Down
2 changes: 0 additions & 2 deletions filetype/types/video.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import

from .base import Type
from .isobmff import IsoBmff

Expand Down
7 changes: 1 addition & 6 deletions filetype/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# -*- coding: utf-8 -*-

# Python 2.7 workaround
try:
import pathlib
except ImportError:
pass

import pathlib

_NUM_SIGNATURE_BYTES = 8192

Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
Expand Down
2 changes: 0 additions & 2 deletions tests/test_benchmark.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import

import os

import filetype
Expand Down
2 changes: 0 additions & 2 deletions tests/test_filetype.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import

import os
import unittest

Expand Down
2 changes: 0 additions & 2 deletions tests/test_types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-

from __future__ import absolute_import

import os
import unittest

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down