Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and mrbean-bremen committed Mar 13, 2024
1 parent 7c24dcd commit 9e62889
Show file tree
Hide file tree
Showing 23 changed files with 48 additions and 38 deletions.
4 changes: 2 additions & 2 deletions pyfakefs/fake_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions pyfakefs/fake_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
>>> stat.S_ISDIR(os_module.stat(os_module.path.dirname(pathname)).st_mode)
True
"""

import errno
import heapq
import os
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions pyfakefs/fake_filesystem_shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
`fake_filesystem_unittest.TestCase`, pytest fs fixture,
or directly `Patcher`.
"""

import os
import shutil
import sys
Expand Down
13 changes: 7 additions & 6 deletions pyfakefs/fake_filesystem_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions pyfakefs/fake_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pyfakefs/fake_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions pyfakefs/fake_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 4 additions & 6 deletions pyfakefs/fake_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]]
Expand Down
1 change: 1 addition & 0 deletions pyfakefs/fake_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
(including PurePosixPath, PosixPath, PureWindowsPath and WindowsPath)
get the properties of the underlying fake filesystem.
"""

import errno
import fnmatch
import functools
Expand Down
1 change: 1 addition & 0 deletions pyfakefs/fake_scandir.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
and the standalone function available in the standalone `scandir` python
package.
"""

import os
import sys

Expand Down
16 changes: 6 additions & 10 deletions pyfakefs/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# limitations under the License.

"""Helper classes use for fake file system implementation."""

import io
import locale
import os
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down
7 changes: 4 additions & 3 deletions pyfakefs/patched_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Provides patches for some commonly used modules that enable them to work
with pyfakefs.
"""

import sys
from importlib import reload

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pyfakefs/pytest_tests/pytest_plugin_failing_helper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Failing test to test stacktrace output - see
"""Failing test to test stacktrace output - see
``pytest_check_failed_plugin_test.py``."""


Expand Down
1 change: 1 addition & 0 deletions pyfakefs/tests/dynamic_patch_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"""
Tests for patching modules loaded after `setUpPyfakefs()`.
"""

import pathlib
import unittest

Expand Down
1 change: 1 addition & 0 deletions pyfakefs/tests/fake_filesystem_shutil_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pyfakefs/tests/fake_filesystem_unittest_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""
Test the :py:class`pyfakefs.fake_filesystem_unittest.TestCase` base class.
"""

import glob
import importlib.util
import io
Expand Down
1 change: 1 addition & 0 deletions pyfakefs/tests/fake_stat_time_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# limitations under the License.

"""Unit tests for file timestamp updates."""

import time
import unittest
from collections import namedtuple
Expand Down
1 change: 1 addition & 0 deletions pyfakefs/tests/fixtures/deprecated_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
over modules. The code is modeled after code in xmlbuilder.py in Python 3.6.
See issue #542.
"""

import warnings


Expand Down
1 change: 1 addition & 0 deletions pyfakefs/tests/import_as_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pyfakefs/tests/mox3_stubout_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pyfakefs/tests/patched_packages_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Provides patches for some commonly used modules that enable them to work
with pyfakefs.
"""

import os
import sys
import unittest
Expand Down
1 change: 1 addition & 0 deletions pyfakefs/tests/performance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pyfakefs/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9e62889

Please sign in to comment.