Skip to content

Commit 00051e4

Browse files
FlavioAmurrioCSEntilZha
authored andcommitted
YATA: Yet another typing attempt.
1 parent 6ed2e9a commit 00051e4

File tree

10 files changed

+481
-240
lines changed

10 files changed

+481
-240
lines changed

.pre-commit-config.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.6.0
6+
hooks:
7+
# - id: trailing-whitespace
8+
# - id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-added-large-files
11+
- repo: https://github.com/psf/black
12+
rev: 24.4.2
13+
hooks:
14+
- id: black
15+
- repo: https://github.com/pre-commit/mirrors-mypy
16+
rev: v1.10.0
17+
hooks:
18+
- id: mypy
19+
additional_dependencies: [types-tabulate]
20+
21+
- repo: https://github.com/astral-sh/ruff-pre-commit
22+
rev: v0.4.2
23+
hooks:
24+
- id: ruff

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#
1212
# All configuration values have a default; values that are commented out
1313
# serve to show the default.
14+
from __future__ import annotations
1415

1516
import sys
1617
import os

functional/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
Package for creating data pipelines, LINQ-style data analysis, and functional programming. Imports
33
the primary entrypoint at streams.seq
44
"""
5-
from functional.streams import seq, pseq
5+
6+
from functional.streams import seq, pseq # noqa: F401
67

78
__author__ = "Pedro Rodriguez"
89
__copyright__ = "Copyright 2024, Pedro Rodriguez"

functional/execution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from functional.util import compose, parallelize
33

44

5-
class ExecutionStrategies(object):
5+
class ExecutionStrategies:
66
"""
77
Enum like object listing the types of execution strategies.
88
"""
@@ -11,7 +11,7 @@ class ExecutionStrategies(object):
1111
PARALLEL = 1
1212

1313

14-
class ExecutionEngine(object):
14+
class ExecutionEngine:
1515
"""
1616
Class to perform serial execution of a Sequence evaluation.
1717
"""

functional/io.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
from __future__ import annotations
12
import gzip
23
import lzma
34
import bz2
45
import io
56
import builtins
67

7-
from typing import Optional, Generic, TypeVar, Any
8+
from typing import Generic, TypeVar, Any
89

910

1011
WRITE_MODE = "wt"
@@ -24,12 +25,12 @@ class ReusableFile(Generic[_FileConv_co]):
2425
def __init__(
2526
self,
2627
path: str,
27-
delimiter: Optional[str] = None,
28+
delimiter: str | None = None,
2829
mode: str = "r",
2930
buffering: int = -1,
30-
encoding: Optional[str] = None,
31-
errors: Optional[str] = None,
32-
newline: Optional[str] = None,
31+
encoding: str | None = None,
32+
errors: str | None = None,
33+
newline: str | None = None,
3334
):
3435
"""
3536
Constructor arguments are passed directly to builtins.open
@@ -81,19 +82,19 @@ def read(self):
8182

8283

8384
class CompressedFile(ReusableFile):
84-
magic_bytes: Optional[bytes] = None
85+
magic_bytes: bytes | None = None
8586

8687
# pylint: disable=too-many-instance-attributes
8788
def __init__(
8889
self,
8990
path: str,
90-
delimiter: Optional[str] = None,
91+
delimiter: str | None = None,
9192
mode: str = "rt",
9293
buffering: int = -1,
9394
compresslevel: int = 9,
94-
encoding: Optional[str] = None,
95-
errors: Optional[str] = None,
96-
newline: Optional[str] = None,
95+
encoding: str | None = None,
96+
errors: str | None = None,
97+
newline: str | None = None,
9798
):
9899
super(CompressedFile, self).__init__(
99100
path,
@@ -118,13 +119,13 @@ class GZFile(CompressedFile):
118119
def __init__(
119120
self,
120121
path: str,
121-
delimiter: Optional[str] = None,
122+
delimiter: str | None = None,
122123
mode: str = "rt",
123124
buffering: int = -1,
124125
compresslevel: int = 9,
125-
encoding: Optional[str] = None,
126-
errors: Optional[str] = None,
127-
newline: Optional[str] = None,
126+
encoding: str | None = None,
127+
errors: str | None = None,
128+
newline: str | None = None,
128129
):
129130
super(GZFile, self).__init__(
130131
path,
@@ -173,13 +174,13 @@ class BZ2File(CompressedFile):
173174
def __init__(
174175
self,
175176
path: str,
176-
delimiter: Optional[str] = None,
177+
delimiter: str | None = None,
177178
mode: str = "rt",
178179
buffering: int = -1,
179180
compresslevel: int = 9,
180-
encoding: Optional[str] = None,
181-
errors: Optional[str] = None,
182-
newline: Optional[str] = None,
181+
encoding: str | None = None,
182+
errors: str | None = None,
183+
newline: str | None = None,
183184
):
184185
super(BZ2File, self).__init__(
185186
path,
@@ -297,15 +298,15 @@ def universal_write_open(
297298
path: str,
298299
mode: str,
299300
buffering: int = -1,
300-
encoding: Optional[str] = None,
301-
errors: Optional[str] = None,
302-
newline: Optional[str] = None,
301+
encoding: str | None = None,
302+
errors: str | None = None,
303+
newline: str | None = None,
303304
compresslevel: int = 9,
304-
format: Optional[int] = None,
305+
format: int | None = None,
305306
check: int = -1,
306-
preset: Optional[int] = None,
307+
preset: int | None = None,
307308
filters: Any = None,
308-
compression: Optional[str] = None,
309+
compression: str | None = None,
309310
):
310311
# pylint: disable=unexpected-keyword-arg,no-member
311312
if compression is None:

functional/lineage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from functional.transformations import CACHE_T
33

44

5-
class Lineage(object):
5+
class Lineage:
66
"""
77
Class for tracking the lineage of transformations, and applying them to a given sequence.
88
"""

0 commit comments

Comments
 (0)