Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 1.25 #84

Merged
merged 2 commits into from
Jun 19, 2024
Merged
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
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
include:
- os: macos-latest
python-version: '3.13'
Expand All @@ -36,10 +36,12 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements-test.txt
pip install coveralls black==24.4.2 flake8 setuptools wheel twine
pip install coveralls flake8 setuptools wheel twine

- name: Verify Code with Black
if: ${{ matrix.python-version != '3.7' }}
run: |
pip install black==24.4.2
black --check puremagic test

- name: Lint with flake8
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

Version 1.25
------------

- Changing to support Python 3.7 again

Version 1.24
------------

Expand Down
8 changes: 5 additions & 3 deletions puremagic/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from itertools import chain

__author__ = "Chris Griffith"
__version__ = "1.24"
__version__ = "1.25"
__all__ = [
"magic_file",
"magic_string",
Expand Down Expand Up @@ -433,8 +433,10 @@ def what(file: os.PathLike | str | None, h: bytes | None = None, imghdr_strict:
"""
if isinstance(h, str):
raise TypeError("h must be bytes, not str. Consider using bytes.fromhex(h)")
if h and imghdr_strict and (ext := imghdr_bug_for_bug.get(h)):
return ext
if h and imghdr_strict:
ext = imghdr_bug_for_bug.get(h)
if ext:
return ext
try:
ext = (from_string(h) if h else from_file(file or "")).lstrip(".")
except PureError:
Expand Down