Skip to content

Commit 62f1fee

Browse files
committed
45 | Remove redundant typing imports
1 parent eadb584 commit 62f1fee

27 files changed

+227
-229
lines changed

docs/source/guides/create_own_components.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Example implementation
116116

117117
.. code-block:: python
118118
119-
from typing import Any, List, Optional
119+
from typing import Any, Optional
120120
121121
from flask_inputfilter.Exception import ValidationError
122122
from flask_inputfilter.Validator import BaseValidator

docs/source/options/filter.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ Converts a dictionary to a specified dataclass.
353353

354354
**Parameters:**
355355

356-
- **dataclass_type** (*Type[dict]*): The target dataclass type that the dictionary should be converted into.
356+
- **dataclass_type** (*type[dict]*): The target dataclass type that the dictionary should be converted into.
357357

358358
**Expected Behavior:**
359359
If the input is a dictionary, it instantiates the provided dataclass using the dictionary values. Otherwise, the input is returned unchanged.
@@ -464,7 +464,7 @@ Converts a value to an instance of a specified Enum.
464464

465465
**Parameters:**
466466

467-
- **enum_class** (*Type[Enum]*): The enum class to which the input should be converted.
467+
- **enum_class** (*type[Enum]*): The enum class to which the input should be converted.
468468

469469
**Expected Behavior:**
470470

@@ -712,7 +712,7 @@ Converts a dictionary into an instance of a specified TypedDict.
712712

713713
**Parameters:**
714714

715-
- **typed_dict** (*Type[TypedDict]*): The target TypedDict type.
715+
- **typed_dict** (*type[TypedDict]*): The target TypedDict type.
716716

717717
**Expected Behavior:**
718718

docs/source/options/validator.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ Verifies that a given value is a valid member of a specified Enum class.
354354

355355
**Parameters:**
356356

357-
- **enumClass** (*Type[Enum]*): The Enum to validate against.
357+
- **enumClass** (*type[Enum]*): The Enum to validate against.
358358
- **error_message** (*Optional[str]*): Custom error message if validation fails.
359359

360360
**Expected Behavior:**
@@ -508,7 +508,7 @@ Validates that the provided value conforms to a specific dataclass type.
508508

509509
**Parameters:**
510510

511-
- **dataclass_type** (*Type[dict]*): The expected dataclass type.
511+
- **dataclass_type** (*type[dict]*): The expected dataclass type.
512512
- **error_message** (*Optional[str]*): Custom error message if validation fails.
513513

514514
**Expected Behavior:**
@@ -687,7 +687,7 @@ Validates that the provided value is an instance of a specified class.
687687

688688
**Parameters:**
689689

690-
- **classType** (*Type[Any]*): The class against which the value is validated.
690+
- **classType** (*type[Any]*): The class against which the value is validated.
691691
- **error_message** (*Optional[str]*): Custom error message if the validation fails.
692692

693693
**Expected Behavior:**
@@ -978,7 +978,7 @@ Validates that the provided value conforms to a specified TypedDict structure.
978978

979979
**Parameters:**
980980

981-
- **typed_dict_type** (*Type[TypedDict]*): The TypedDict class that defines the expected structure.
981+
- **typed_dict_type** (*type[TypedDict]*): The TypedDict class that defines the expected structure.
982982
- **error_message** (*Optional[str]*): Custom error message if the validation fails.
983983

984984
**Expected Behavior:**

env_configs/cython.Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ FROM python:3.7-slim
22

33
WORKDIR /app
44

5-
RUN apt-get update && apt-get install -y g++ git
5+
RUN apt-get update \
6+
&& apt-get install -y g++ git \
7+
&& apt-get clean
68

79
COPY pyproject.toml /app
810

env_configs/env.Dockerfile

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,37 @@ FROM debian:buster-slim
22

33
WORKDIR /app
44

5-
RUN apt-get update && apt-get install -y \
6-
build-essential \
7-
curl \
8-
g++ \
9-
git \
10-
libbz2-dev \
11-
libffi-dev \
12-
libjpeg-dev \
13-
liblzma-dev \
14-
libncurses5-dev \
15-
libncursesw5-dev \
16-
libreadline-dev \
17-
libsqlite3-dev \
18-
libssl-dev \
19-
llvm \
20-
make \
21-
python3-dev \
22-
tk-dev \
23-
wget \
24-
xz-utils \
25-
zlib1g-dev
5+
RUN apt-get update \
6+
&& apt-get install -y \
7+
build-essential \
8+
curl \
9+
g++ \
10+
git \
11+
libbz2-dev \
12+
libffi-dev \
13+
libjpeg-dev \
14+
liblzma-dev \
15+
libncurses5-dev \
16+
libncursesw5-dev \
17+
libreadline-dev \
18+
libsqlite3-dev \
19+
libssl-dev \
20+
llvm \
21+
make \
22+
python3-dev \
23+
tk-dev \
24+
wget \
25+
xz-utils \
26+
zlib1g-dev \
27+
&& apt-get clean
2628

2729
RUN curl https://pyenv.run | bash
2830

2931
ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:/root/.pyenv/versions/3.7.12/bin:$PATH"
30-
RUN echo 'export PATH="/root/.pyenv/bin:$PATH"' >> ~/.bashrc
31-
RUN echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
32-
RUN echo 'eval "$(pyenv init -)"' >> ~/.bashrc
33-
RUN echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
32+
RUN echo 'export PATH="/root/.pyenv/bin:$PATH"' >> ~/.bashrc \
33+
&& echo 'eval "$(pyenv init --path)"' >> ~/.bashrc \
34+
&& echo 'eval "$(pyenv init -)"' >> ~/.bashrc \
35+
&& echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
3436

3537
RUN /root/.pyenv/bin/pyenv install 3.7.12
3638
RUN /root/.pyenv/bin/pyenv install 3.8.12

env_configs/pure.Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ FROM python:3.7-slim
22

33
WORKDIR /app
44

5-
RUN apt-get update && apt-get install -y git
5+
RUN apt-get update \
6+
&& apt-get install -y git \
7+
&& apt-get clean
68

79
COPY pyproject.toml /app
810

flask_inputfilter/Condition/CustomCondition.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

3-
from typing import Any, Callable, Dict
3+
from collections.abc import Callable
4+
from typing import Any, Dict
45

56
from flask_inputfilter.Condition import BaseCondition
67

flask_inputfilter/Filter/Base64ImageDownscaleFilter.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from __future__ import annotations
22

33
import base64
4-
import binascii
54
import io
65
from typing import Any, Optional
76

8-
from PIL import Image, UnidentifiedImageError
7+
from PIL import Image
98

109
from flask_inputfilter.Filter import BaseFilter
1110

@@ -39,13 +38,7 @@ def apply(self, value: Any) -> Any:
3938
image = Image.open(io.BytesIO(base64.b64decode(value)))
4039
return self.resize_picture(image)
4140

42-
except (
43-
binascii.Error,
44-
UnidentifiedImageError,
45-
OSError,
46-
ValueError,
47-
TypeError,
48-
):
41+
except (OSError, ValueError, TypeError):
4942
return value
5043

5144
def resize_picture(self, image: Image) -> str:

flask_inputfilter/Filter/Base64ImageResizeFilter.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from __future__ import annotations
22

33
import base64
4-
import binascii
54
import io
65
from typing import Any
76

8-
from PIL import Image, UnidentifiedImageError
7+
from PIL import Image
98

109
from flask_inputfilter.Enum import ImageFormatEnum
1110
from flask_inputfilter.Filter import BaseFilter
@@ -46,13 +45,7 @@ def apply(self, value: Any) -> Any:
4645

4746
value = Image.open(io.BytesIO(base64.b64decode(value)))
4847
return self.reduce_image(value)
49-
except (
50-
binascii.Error,
51-
UnidentifiedImageError,
52-
OSError,
53-
ValueError,
54-
TypeError,
55-
):
48+
except (OSError, ValueError, TypeError):
5649
return value
5750

5851
def reduce_image(self, image: Image) -> Image:

flask_inputfilter/Filter/ToDataclassFilter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import Any, Type, Union
3+
from typing import Any, Union
44

55
from flask_inputfilter.Filter import BaseFilter
66

@@ -12,7 +12,7 @@ class ToDataclassFilter(BaseFilter):
1212

1313
__slots__ = ("dataclass_type",)
1414

15-
def __init__(self, dataclass_type: Type[dict]) -> None:
15+
def __init__(self, dataclass_type: type[dict]) -> None:
1616
self.dataclass_type = dataclass_type
1717

1818
def apply(self, value: Any) -> Union[Any]:

0 commit comments

Comments
 (0)