From 467b19e36dc239d434d7d6275d5cecca87241589 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Sat, 31 Aug 2024 11:00:18 +0100 Subject: [PATCH] Remove pillow as a dependency (#1891) --- .pre-commit-config.yaml | 2 +- constraints.txt | 6 ++---- jira/client.py | 7 +++++-- pyproject.toml | 1 - 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7c00d4df0..3592a9cf1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,7 @@ repos: additional_dependencies: - tomli; python_version<'3.11' - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.6.2" + rev: "v0.6.3" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/constraints.txt b/constraints.txt index 589254686..4940cd460 100644 --- a/constraints.txt +++ b/constraints.txt @@ -14,7 +14,7 @@ backports-tarfile==1.2.0 # via jaraco-context beautifulsoup4==4.12.3 # via furo -certifi==2024.7.4 +certifi==2024.8.30 # via requests cffi==1.17.0 # via cryptography @@ -106,8 +106,6 @@ parso==0.8.4 # via jedi pexpect==4.9.0 # via ipython -pillow==10.4.0 - # via jira (pyproject.toml) pluggy==1.5.0 # via pytest prompt-toolkit==3.0.47 @@ -232,5 +230,5 @@ wheel==0.44.0 # via jira (pyproject.toml) yanc==0.3.3 # via jira (pyproject.toml) -zipp==3.20.0 +zipp==3.20.1 # via importlib-metadata diff --git a/jira/client.py b/jira/client.py index 8c1702c04..1dd5197b2 100644 --- a/jira/client.py +++ b/jira/client.py @@ -18,6 +18,7 @@ import os import re import sys +import tempfile import time import urllib import warnings @@ -40,7 +41,6 @@ import requests from packaging.version import parse as parse_version -from PIL import Image from requests import Response from requests.auth import AuthBase from requests.structures import CaseInsensitiveDict @@ -4453,7 +4453,10 @@ def _get_mime_type(self, buff: bytes) -> str | None: if self._magic is not None: return self._magic.id_buffer(buff) try: - return mimetypes.guess_type("f." + Image.open(buff).format)[0] + with tempfile.TemporaryFile() as f: + f.write(buff) + return mimetypes.guess_type(f.name)[0] + return mimetypes.guess_type(f.name)[0] except (OSError, TypeError): self.log.warning( "Couldn't detect content type of avatar image" diff --git a/pyproject.toml b/pyproject.toml index 8878969f9..241842f37 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,6 @@ keywords = ["api", "atlassian", "jira", "rest", "web"] dependencies = [ "defusedxml", "packaging", - "Pillow>=2.1.0", "requests-oauthlib>=1.1.0", "requests>=2.10.0", "requests_toolbelt",