Skip to content

Commit c2811b2

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent b762c0f commit c2811b2

30 files changed

Lines changed: 148 additions & 183 deletions

pyfakefs/fake_file.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,37 @@
2222
import sys
2323
import traceback
2424
import weakref
25+
from collections.abc import Callable, Iterator
2526
from stat import (
26-
S_IFREG,
2727
S_IFDIR,
28+
S_IFREG,
2829
)
2930
from types import TracebackType
3031
from typing import (
31-
Union,
32+
TYPE_CHECKING,
3233
Any,
33-
cast,
3434
AnyStr,
3535
NoReturn,
3636
TextIO,
37-
TYPE_CHECKING,
37+
Union,
38+
cast,
3839
)
3940

40-
from collections.abc import Callable, Iterator
41-
4241
from pyfakefs import helpers
4342
from pyfakefs.helpers import (
44-
FakeStatResult,
43+
AnyPath,
44+
AnyString,
4545
BinaryBufferIO,
46+
FakeStatResult,
4647
TextBufferIO,
48+
_OpenModes,
49+
get_locale_encoding,
4750
is_int_type,
51+
is_root,
4852
is_unicode_string,
49-
to_string,
5053
matching_string,
5154
real_encoding,
52-
AnyPath,
53-
AnyString,
54-
get_locale_encoding,
55-
_OpenModes,
56-
is_root,
55+
to_string,
5756
)
5857

5958
if TYPE_CHECKING:

pyfakefs/fake_filesystem.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -92,42 +92,40 @@
9292
import sys
9393
import tempfile
9494
import weakref
95-
from collections import namedtuple, OrderedDict
95+
from collections import OrderedDict, namedtuple
96+
from collections.abc import Callable
9697
from doctest import TestResults
9798
from enum import Enum
98-
9999
from stat import (
100-
S_IFREG,
101100
S_IFDIR,
102-
S_ISLNK,
101+
S_IFLNK,
103102
S_IFMT,
103+
S_IFREG,
104104
S_ISDIR,
105-
S_IFLNK,
105+
S_ISLNK,
106106
S_ISREG,
107107
)
108108
from typing import (
109+
TYPE_CHECKING,
109110
Any,
110-
cast,
111111
AnyStr,
112-
overload,
113112
NoReturn,
114-
TYPE_CHECKING,
113+
cast,
114+
overload,
115115
)
116116

117-
from collections.abc import Callable
118-
119-
from pyfakefs import fake_file, fake_path, fake_io, fake_os, helpers, fake_open
120-
from pyfakefs.fake_file import AnyFileWrapper, AnyFile
117+
from pyfakefs import fake_file, fake_io, fake_open, fake_os, fake_path, helpers
118+
from pyfakefs.fake_file import AnyFile, AnyFileWrapper
121119
from pyfakefs.helpers import (
122-
is_int_type,
123-
make_string_path,
124-
to_string,
125-
matching_string,
120+
POSIX_PROPERTIES,
121+
WINDOWS_PROPERTIES,
126122
AnyPath,
127123
AnyString,
128-
WINDOWS_PROPERTIES,
129-
POSIX_PROPERTIES,
130124
FSType,
125+
is_int_type,
126+
make_string_path,
127+
matching_string,
128+
to_string,
131129
)
132130

133131
if TYPE_CHECKING:
@@ -2569,7 +2567,7 @@ def add_package_metadata(self, package_name: str) -> None:
25692567
Raises:
25702568
PackageNotFoundError: if the package with the given name is not found
25712569
"""
2572-
from importlib.metadata import distribution, PackageNotFoundError
2570+
from importlib.metadata import PackageNotFoundError, distribution
25732571

25742572
# we have to pause patching to get the distribution
25752573
# from the real filesystem if we are in patch mode
@@ -3296,6 +3294,7 @@ def _create_temp_dir(self):
32963294

32973295
def _run_doctest() -> TestResults:
32983296
import doctest
3297+
32993298
import pyfakefs
33003299

33013300
return doctest.testmod(pyfakefs.fake_filesystem)

pyfakefs/fake_filesystem_shutil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
import os
3535
import shutil
3636
import sys
37-
from threading import RLock
3837
from collections.abc import Callable
38+
from threading import RLock
3939
from typing import TYPE_CHECKING
4040

4141
if TYPE_CHECKING:

pyfakefs/fake_filesystem_unittest.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,36 @@
5151
import unittest
5252
import warnings
5353
import weakref
54+
from collections.abc import Callable, ItemsView, Iterator, Sequence
5455
from importlib import reload
5556
from importlib.abc import Loader, MetaPathFinder
5657
from importlib.machinery import ModuleSpec
57-
from importlib.util import spec_from_file_location, module_from_spec
58-
from types import ModuleType, TracebackType, FunctionType
58+
from importlib.util import module_from_spec, spec_from_file_location
59+
from types import FunctionType, ModuleType, TracebackType
5960
from typing import (
6061
Any,
6162
Optional,
6263
cast,
6364
)
64-
65-
from collections.abc import Callable, Iterator, ItemsView, Sequence
6665
from unittest import TestSuite
6766

68-
from pyfakefs import fake_filesystem, fake_io, fake_os, fake_open, fake_path, fake_file
69-
from pyfakefs import fake_filesystem_shutil
70-
from pyfakefs import fake_pathlib
71-
from pyfakefs import mox3_stubout
67+
from pyfakefs import (
68+
fake_file,
69+
fake_filesystem,
70+
fake_filesystem_shutil,
71+
fake_io,
72+
fake_open,
73+
fake_os,
74+
fake_path,
75+
fake_pathlib,
76+
mox3_stubout,
77+
)
7278
from pyfakefs.fake_filesystem import (
73-
set_uid,
74-
set_gid,
75-
reset_ids,
76-
PatchMode,
7779
FakeFilesystem,
80+
PatchMode,
81+
reset_ids,
82+
set_gid,
83+
set_uid,
7884
)
7985
from pyfakefs.fake_os import use_original_os
8086
from pyfakefs.helpers import IS_PYPY, IS_WIN
@@ -554,9 +560,9 @@ class Patcher:
554560
SKIPMODULES.add(nt)
555561
SKIPMODULES.add(ntpath)
556562
else:
563+
import fcntl
557564
import posix
558565
import posixpath
559-
import fcntl
560566

561567
SKIPMODULES.add(posix)
562568
SKIPMODULES.add(posixpath)
@@ -725,10 +731,10 @@ def __init__(
725731

726732
if use_known_patches:
727733
from pyfakefs.patched_packages import (
728-
get_modules_to_patch,
729734
get_classes_to_patch,
730-
get_fake_module_classes,
731735
get_cleanup_handlers,
736+
get_fake_module_classes,
737+
get_modules_to_patch,
732738
)
733739

734740
modules_to_patch = modules_to_patch or {}
@@ -1250,7 +1256,7 @@ def __enter__(self) -> FakeFilesystem:
12501256
self._fs.pause()
12511257
return self._fs
12521258

1253-
def __exit__(self, *args: Any) -> None:
1259+
def __exit__(self, *args: object) -> None:
12541260
self._fs.resume()
12551261

12561262

pyfakefs/fake_io.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@
2121
import _io # pytype: disable=import-error
2222
import io
2323
import sys
24+
from collections.abc import Callable
2425
from enum import Enum
2526
from typing import (
26-
Any,
27-
AnyStr,
2827
IO,
2928
TYPE_CHECKING,
29+
Any,
30+
AnyStr,
3031
)
3132

32-
from collections.abc import Callable
33-
3433
from pyfakefs.fake_file import AnyFileWrapper
3534
from pyfakefs.fake_open import fake_open
3635
from pyfakefs.helpers import IS_PYPY, is_called_from_skipped_module

pyfakefs/fake_open.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,29 @@
2525
S_ISDIR,
2626
)
2727
from typing import (
28+
IO,
29+
TYPE_CHECKING,
2830
Any,
29-
cast,
3031
AnyStr,
31-
TYPE_CHECKING,
32-
IO,
32+
cast,
3333
)
3434

35+
from pyfakefs import helpers
3536
from pyfakefs.fake_file import (
37+
AnyFileWrapper,
3638
FakeBinaryFileWrapper,
37-
FakeTextFileWrapper,
38-
FakePipeWrapper,
39-
FakeFileWrapper,
4039
FakeFile,
41-
AnyFileWrapper,
40+
FakeFileWrapper,
41+
FakePipeWrapper,
42+
FakeTextFileWrapper,
4243
)
43-
from pyfakefs import helpers
4444
from pyfakefs.helpers import (
45-
AnyString,
46-
is_called_from_skipped_module,
47-
is_root,
4845
PERM_READ,
4946
PERM_WRITE,
47+
AnyString,
5048
_OpenModes,
49+
is_called_from_skipped_module,
50+
is_root,
5151
is_unfaked_path,
5252
)
5353

pyfakefs/fake_os.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,48 +24,47 @@
2424
import os
2525
import sys
2626
import uuid
27+
from collections.abc import Callable
2728
from contextlib import contextmanager
2829
from stat import (
2930
S_IFREG,
3031
S_IFSOCK,
3132
)
3233
from typing import (
34+
TYPE_CHECKING,
3335
Any,
34-
cast,
3536
AnyStr,
36-
TYPE_CHECKING,
37+
cast,
3738
)
3839

39-
from collections.abc import Callable
40-
4140
from pyfakefs.fake_file import (
41+
AnyFileWrapper,
4242
FakeDirectory,
4343
FakeDirWrapper,
44-
StandardStreamWrapper,
44+
FakeFile,
4545
FakeFileWrapper,
4646
FakePipeWrapper,
47-
FakeFile,
48-
AnyFileWrapper,
47+
StandardStreamWrapper,
4948
)
5049
from pyfakefs.fake_open import FakeFileOpen, _OpenModes
5150
from pyfakefs.fake_path import FakePathModule
52-
from pyfakefs.fake_scandir import scandir, walk, ScanDirIter
51+
from pyfakefs.fake_scandir import ScanDirIter, scandir, walk
5352
from pyfakefs.helpers import (
53+
IS_PYPY,
54+
PERM_DEF,
55+
PERM_EXE,
56+
AnyString,
5457
FakeStatResult,
58+
get_gid,
59+
get_uid,
60+
is_byte_string,
5561
is_called_from_skipped_module,
5662
is_int_type,
57-
is_byte_string,
63+
is_root,
5864
make_string_path,
59-
IS_PYPY,
60-
to_string,
6165
matching_string,
62-
AnyString,
6366
to_bytes,
64-
PERM_EXE,
65-
PERM_DEF,
66-
is_root,
67-
get_uid,
68-
get_gid,
67+
to_string,
6968
)
7069

7170
if TYPE_CHECKING:

pyfakefs/fake_path.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,26 @@
2121
import inspect
2222
import os
2323
import sys
24+
from collections.abc import Callable
2425
from stat import (
2526
S_IFDIR,
2627
S_IFMT,
2728
)
2829
from types import ModuleType
2930
from typing import (
31+
TYPE_CHECKING,
3032
Any,
3133
AnyStr,
32-
overload,
3334
ClassVar,
34-
TYPE_CHECKING,
35+
overload,
3536
)
3637

37-
from collections.abc import Callable
38-
3938
from pyfakefs.helpers import (
4039
is_called_from_skipped_module,
4140
make_string_path,
42-
to_string,
4341
matching_string,
4442
to_bytes,
43+
to_string,
4544
)
4645

4746
if TYPE_CHECKING:

pyfakefs/fake_pathlib.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@
3535
import re
3636
import sys
3737
import warnings
38-
from pathlib import PurePath
39-
4038
from collections.abc import Callable
39+
from pathlib import PurePath
4140
from typing import Any, Union
4241
from unittest import mock
4342
from urllib.parse import quote_from_bytes as urlquote_from_bytes
@@ -47,8 +46,7 @@
4746
from pyfakefs.fake_open import fake_open
4847
from pyfakefs.fake_os import FakeOsModule, use_original_os
4948
from pyfakefs.fake_path import FakePathModule
50-
from pyfakefs.helpers import IS_PYPY, is_called_from_skipped_module, FSType
51-
49+
from pyfakefs.helpers import IS_PYPY, FSType, is_called_from_skipped_module
5250

5351
_WIN_RESERVED_NAMES = (
5452
{"CON", "PRN", "AUX", "NUL"}

0 commit comments

Comments
 (0)