From eb0e8d08c435780c3f0dde85bbcf1887af09d580 Mon Sep 17 00:00:00 2001 From: Tyler Cook <10459406+cilki@users.noreply.github.com> Date: Sun, 31 Mar 2024 12:20:53 -0500 Subject: [PATCH 1/2] Replace pillow dependency with filetype --- constraints.txt | 2 +- jira/client.py | 11 +++++------ pyproject.toml | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/constraints.txt b/constraints.txt index 9d59e9a7e..c1b22b7fb 100644 --- a/constraints.txt +++ b/constraints.txt @@ -105,7 +105,7 @@ parso==0.8.3 # via jedi pickleshare==0.7.5 # via ipython -pillow==10.2.0 +filetype==1.2.0 # via jira (setup.cfg) pluggy==1.4.0 # via pytest diff --git a/jira/client.py b/jira/client.py index ff311bcd6..b5a557a04 100644 --- a/jira/client.py +++ b/jira/client.py @@ -14,7 +14,6 @@ import hashlib import json import logging as _logging -import mimetypes import os import re import sys @@ -41,8 +40,8 @@ from urllib.parse import parse_qs, quote, urlparse import requests +import filetype 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 @@ -4424,14 +4423,14 @@ 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] - except (OSError, TypeError): + + mimetype = filetype.guess_mime(buff) + if not mimetype: self.log.warning( "Couldn't detect content type of avatar image" ". Specify the 'contentType' parameter explicitly." ) - return None + return mimetype def rename_user(self, old_user: str, new_user: str): """Rename a Jira user. diff --git a/pyproject.toml b/pyproject.toml index 133e1bf3d..831e6b3ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ keywords = ["api", "atlassian", "jira", "rest", "web"] dependencies = [ "defusedxml", "packaging", - "Pillow>=2.1.0", + "filetype>=1.2.0", "requests-oauthlib>=1.1.0", "requests>=2.10.0", "requests_toolbelt", From 81f2395c222aa678c0cad98f63908460b1153b17 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 31 Mar 2024 17:22:18 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- jira/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jira/client.py b/jira/client.py index b5a557a04..29cf557ec 100644 --- a/jira/client.py +++ b/jira/client.py @@ -39,8 +39,8 @@ ) from urllib.parse import parse_qs, quote, urlparse -import requests import filetype +import requests from packaging.version import parse as parse_version from requests import Response from requests.auth import AuthBase