From 9e628896e6b4db37b86a5e8e8fe3431d8bddadb8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 13 Mar 2024 00:40:09 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- pyfakefs/fake_file.py | 4 ++-- pyfakefs/fake_filesystem.py | 7 +++---- pyfakefs/fake_filesystem_shutil.py | 1 + pyfakefs/fake_filesystem_unittest.py | 13 +++++++------ pyfakefs/fake_io.py | 5 +++-- pyfakefs/fake_open.py | 4 ++-- pyfakefs/fake_os.py | 5 +++-- pyfakefs/fake_path.py | 10 ++++------ pyfakefs/fake_pathlib.py | 1 + pyfakefs/fake_scandir.py | 1 + pyfakefs/helpers.py | 16 ++++++---------- pyfakefs/patched_packages.py | 7 ++++--- .../pytest_tests/pytest_plugin_failing_helper.py | 2 +- pyfakefs/tests/dynamic_patch_test.py | 1 + pyfakefs/tests/fake_filesystem_shutil_test.py | 1 + pyfakefs/tests/fake_filesystem_unittest_test.py | 1 + pyfakefs/tests/fake_stat_time_test.py | 1 + pyfakefs/tests/fixtures/deprecated_property.py | 1 + pyfakefs/tests/import_as_example.py | 1 + pyfakefs/tests/mox3_stubout_example.py | 1 + pyfakefs/tests/patched_packages_test.py | 1 + pyfakefs/tests/performance_test.py | 1 + pyfakefs/tests/test_utils.py | 1 + 23 files changed, 48 insertions(+), 38 deletions(-) diff --git a/pyfakefs/fake_file.py b/pyfakefs/fake_file.py index c73b9efb..fb2267c5 100644 --- a/pyfakefs/fake_file.py +++ b/pyfakefs/fake_file.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""Fake implementations for different file objects. -""" +"""Fake implementations for different file objects.""" + import errno import io import os diff --git a/pyfakefs/fake_filesystem.py b/pyfakefs/fake_filesystem.py index b0077d5f..1345a0ff 100644 --- a/pyfakefs/fake_filesystem.py +++ b/pyfakefs/fake_filesystem.py @@ -80,6 +80,7 @@ >>> stat.S_ISDIR(os_module.stat(os_module.path.dirname(pathname)).st_mode) True """ + import errno import heapq import os @@ -1221,12 +1222,10 @@ def joinpaths(self, *paths: AnyStr) -> AnyStr: return matching_string(file_paths[0], "").join(joined_path_segments) @overload - def _path_components(self, path: str) -> List[str]: - ... + def _path_components(self, path: str) -> List[str]: ... @overload - def _path_components(self, path: bytes) -> List[bytes]: - ... + def _path_components(self, path: bytes) -> List[bytes]: ... def _path_components(self, path: AnyStr) -> List[AnyStr]: """Breaks the path into a list of component names. diff --git a/pyfakefs/fake_filesystem_shutil.py b/pyfakefs/fake_filesystem_shutil.py index 561ccd23..d3f4ea5f 100755 --- a/pyfakefs/fake_filesystem_shutil.py +++ b/pyfakefs/fake_filesystem_shutil.py @@ -26,6 +26,7 @@ `fake_filesystem_unittest.TestCase`, pytest fs fixture, or directly `Patcher`. """ + import os import shutil import sys diff --git a/pyfakefs/fake_filesystem_unittest.py b/pyfakefs/fake_filesystem_unittest.py index cc684753..f7fb6e74 100644 --- a/pyfakefs/fake_filesystem_unittest.py +++ b/pyfakefs/fake_filesystem_unittest.py @@ -35,6 +35,7 @@ pyfakefs by simply changing their base class from `:py:class`unittest.TestCase` to `:py:class`pyfakefs.fake_filesystem_unittest.TestCase`. """ + import _io # type:ignore[import] import doctest import functools @@ -730,12 +731,12 @@ def _init_fake_module_functions(self) -> None: fake_module = fake_filesystem.FakePathModule for fct_name in fake_module.dir(): module_attr = (getattr(fake_module, fct_name), PATH_MODULE) - self._fake_module_functions.setdefault(fct_name, {})[ - "genericpath" - ] = module_attr - self._fake_module_functions.setdefault(fct_name, {})[ - PATH_MODULE - ] = module_attr + self._fake_module_functions.setdefault(fct_name, {})["genericpath"] = ( + module_attr + ) + self._fake_module_functions.setdefault(fct_name, {})[PATH_MODULE] = ( + module_attr + ) def __enter__(self) -> "Patcher": """Context manager for usage outside of diff --git a/pyfakefs/fake_io.py b/pyfakefs/fake_io.py index 372df484..1313e73f 100644 --- a/pyfakefs/fake_io.py +++ b/pyfakefs/fake_io.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" Uses :py:class:`FakeIoModule` to provide a - fake ``io`` module replacement. +"""Uses :py:class:`FakeIoModule` to provide a +fake ``io`` module replacement. """ + import _io # pytype: disable=import-error import io import os diff --git a/pyfakefs/fake_open.py b/pyfakefs/fake_open.py index 29fea3d5..b929b2e6 100644 --- a/pyfakefs/fake_open.py +++ b/pyfakefs/fake_open.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""A fake open() function replacement. See ``fake_filesystem`` for usage. -""" +"""A fake open() function replacement. See ``fake_filesystem`` for usage.""" + import errno import os import sys diff --git a/pyfakefs/fake_os.py b/pyfakefs/fake_os.py index 68f7752f..d2f3f248 100644 --- a/pyfakefs/fake_os.py +++ b/pyfakefs/fake_os.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" Uses :py:class:`FakeOsModule` to provide a - fake :py:mod:`os` module replacement. +"""Uses :py:class:`FakeOsModule` to provide a +fake :py:mod:`os` module replacement. """ + import errno import functools import inspect diff --git a/pyfakefs/fake_path.py b/pyfakefs/fake_path.py index e6b261bf..5135f746 100644 --- a/pyfakefs/fake_path.py +++ b/pyfakefs/fake_path.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" Faked ``os.path`` module replacement. See ``fake_filesystem`` for usage. -""" +"""Faked ``os.path`` module replacement. See ``fake_filesystem`` for usage.""" + import errno import os import sys @@ -368,14 +368,12 @@ def samefile(self, path1: AnyStr, path2: AnyStr) -> bool: @overload def _join_real_path( self, path: str, rest: str, seen: Dict[str, Optional[str]] - ) -> Tuple[str, bool]: - ... + ) -> Tuple[str, bool]: ... @overload def _join_real_path( self, path: bytes, rest: bytes, seen: Dict[bytes, Optional[bytes]] - ) -> Tuple[bytes, bool]: - ... + ) -> Tuple[bytes, bool]: ... def _join_real_path( self, path: AnyStr, rest: AnyStr, seen: Dict[AnyStr, Optional[AnyStr]] diff --git a/pyfakefs/fake_pathlib.py b/pyfakefs/fake_pathlib.py index 96791af0..c595b7fd 100644 --- a/pyfakefs/fake_pathlib.py +++ b/pyfakefs/fake_pathlib.py @@ -28,6 +28,7 @@ (including PurePosixPath, PosixPath, PureWindowsPath and WindowsPath) get the properties of the underlying fake filesystem. """ + import errno import fnmatch import functools diff --git a/pyfakefs/fake_scandir.py b/pyfakefs/fake_scandir.py index e01f0681..75f8caa4 100644 --- a/pyfakefs/fake_scandir.py +++ b/pyfakefs/fake_scandir.py @@ -16,6 +16,7 @@ and the standalone function available in the standalone `scandir` python package. """ + import os import sys diff --git a/pyfakefs/helpers.py b/pyfakefs/helpers.py index a5d8d5b8..71cc1787 100644 --- a/pyfakefs/helpers.py +++ b/pyfakefs/helpers.py @@ -11,6 +11,7 @@ # limitations under the License. """Helper classes use for fake file system implementation.""" + import io import locale import os @@ -116,13 +117,11 @@ def get_locale_encoding(): @overload -def make_string_path(dir_name: AnyStr) -> AnyStr: - ... +def make_string_path(dir_name: AnyStr) -> AnyStr: ... @overload -def make_string_path(dir_name: os.PathLike) -> str: - ... +def make_string_path(dir_name: os.PathLike) -> str: ... def make_string_path(dir_name: AnyPath) -> AnyStr: # type: ignore[type-var] @@ -164,18 +163,15 @@ def now(): @overload -def matching_string(matched: bytes, string: AnyStr) -> bytes: - ... +def matching_string(matched: bytes, string: AnyStr) -> bytes: ... @overload -def matching_string(matched: str, string: AnyStr) -> str: - ... +def matching_string(matched: str, string: AnyStr) -> str: ... @overload -def matching_string(matched: AnyStr, string: None) -> None: - ... +def matching_string(matched: AnyStr, string: None) -> None: ... def matching_string( # type: ignore[misc] diff --git a/pyfakefs/patched_packages.py b/pyfakefs/patched_packages.py index 6ff927fc..2271e94c 100644 --- a/pyfakefs/patched_packages.py +++ b/pyfakefs/patched_packages.py @@ -14,6 +14,7 @@ Provides patches for some commonly used modules that enable them to work with pyfakefs. """ + import sys from importlib import reload @@ -80,9 +81,9 @@ def reload_handler(name): def get_cleanup_handlers(): handlers = {} if pd is not None: - handlers[ - "pandas.core.arrays.arrow.extension_types" - ] = handle_extension_type_cleanup + handlers["pandas.core.arrays.arrow.extension_types"] = ( + handle_extension_type_cleanup + ) if django is not None: for module_name in django_view_modules(): handlers[module_name] = lambda name=module_name: reload_handler(name) diff --git a/pyfakefs/pytest_tests/pytest_plugin_failing_helper.py b/pyfakefs/pytest_tests/pytest_plugin_failing_helper.py index 08910183..cec614c0 100644 --- a/pyfakefs/pytest_tests/pytest_plugin_failing_helper.py +++ b/pyfakefs/pytest_tests/pytest_plugin_failing_helper.py @@ -1,4 +1,4 @@ -""" Failing test to test stacktrace output - see +"""Failing test to test stacktrace output - see ``pytest_check_failed_plugin_test.py``.""" diff --git a/pyfakefs/tests/dynamic_patch_test.py b/pyfakefs/tests/dynamic_patch_test.py index bb8ac404..8acf7464 100644 --- a/pyfakefs/tests/dynamic_patch_test.py +++ b/pyfakefs/tests/dynamic_patch_test.py @@ -13,6 +13,7 @@ """ Tests for patching modules loaded after `setUpPyfakefs()`. """ + import pathlib import unittest diff --git a/pyfakefs/tests/fake_filesystem_shutil_test.py b/pyfakefs/tests/fake_filesystem_shutil_test.py index 530241db..9043b8dd 100644 --- a/pyfakefs/tests/fake_filesystem_shutil_test.py +++ b/pyfakefs/tests/fake_filesystem_shutil_test.py @@ -17,6 +17,7 @@ Note that almost all of the functionality is delegated to the real `shutil` and works correctly with the fake filesystem because of the faked `os` module. """ + import os import shutil import sys diff --git a/pyfakefs/tests/fake_filesystem_unittest_test.py b/pyfakefs/tests/fake_filesystem_unittest_test.py index 3f5375f7..4a3566e4 100644 --- a/pyfakefs/tests/fake_filesystem_unittest_test.py +++ b/pyfakefs/tests/fake_filesystem_unittest_test.py @@ -17,6 +17,7 @@ """ Test the :py:class`pyfakefs.fake_filesystem_unittest.TestCase` base class. """ + import glob import importlib.util import io diff --git a/pyfakefs/tests/fake_stat_time_test.py b/pyfakefs/tests/fake_stat_time_test.py index 5833ebd9..dfdbaaff 100644 --- a/pyfakefs/tests/fake_stat_time_test.py +++ b/pyfakefs/tests/fake_stat_time_test.py @@ -11,6 +11,7 @@ # limitations under the License. """Unit tests for file timestamp updates.""" + import time import unittest from collections import namedtuple diff --git a/pyfakefs/tests/fixtures/deprecated_property.py b/pyfakefs/tests/fixtures/deprecated_property.py index 9bdb5905..c99fab52 100644 --- a/pyfakefs/tests/fixtures/deprecated_property.py +++ b/pyfakefs/tests/fixtures/deprecated_property.py @@ -14,6 +14,7 @@ over modules. The code is modeled after code in xmlbuilder.py in Python 3.6. See issue #542. """ + import warnings diff --git a/pyfakefs/tests/import_as_example.py b/pyfakefs/tests/import_as_example.py index 74f95059..e83f9602 100644 --- a/pyfakefs/tests/import_as_example.py +++ b/pyfakefs/tests/import_as_example.py @@ -14,6 +14,7 @@ Example module that is used for testing modules that import file system modules to be patched under another name. """ + import os as my_os import pathlib import sys diff --git a/pyfakefs/tests/mox3_stubout_example.py b/pyfakefs/tests/mox3_stubout_example.py index 44dfee90..15aac940 100644 --- a/pyfakefs/tests/mox3_stubout_example.py +++ b/pyfakefs/tests/mox3_stubout_example.py @@ -14,6 +14,7 @@ Example module that is used for testing the functionality of :py:class`pyfakefs.mox_stubout.StubOutForTesting`. """ + import datetime import math import os diff --git a/pyfakefs/tests/patched_packages_test.py b/pyfakefs/tests/patched_packages_test.py index 1c760917..16bbc927 100644 --- a/pyfakefs/tests/patched_packages_test.py +++ b/pyfakefs/tests/patched_packages_test.py @@ -14,6 +14,7 @@ Provides patches for some commonly used modules that enable them to work with pyfakefs. """ + import os import sys import unittest diff --git a/pyfakefs/tests/performance_test.py b/pyfakefs/tests/performance_test.py index 5e44f225..1084be03 100644 --- a/pyfakefs/tests/performance_test.py +++ b/pyfakefs/tests/performance_test.py @@ -10,6 +10,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """Shall provide tests to check performance overhead of pyfakefs.""" + import os import time import unittest diff --git a/pyfakefs/tests/test_utils.py b/pyfakefs/tests/test_utils.py index 94b667bf..e7aded48 100644 --- a/pyfakefs/tests/test_utils.py +++ b/pyfakefs/tests/test_utils.py @@ -15,6 +15,7 @@ # Disable attribute errors - attributes not be found in mixin (shall be cleaned up...) # pytype: disable=attribute-error """Common helper classes used in tests, or as test class base.""" + import os import platform import shutil