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 Jan 14, 2025
1 parent a3b9579 commit 04771e7
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion pyfakefs/fake_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,7 @@ def resolve(
open_file = self.get_open_file(file_path).get_object()
assert isinstance(open_file, FakeFile)
return open_file
raise TypeError("path should be string, bytes or " "os.PathLike, not int")
raise TypeError("path should be string, bytes or os.PathLike, not int")

if follow_symlinks:
return self.get_object_from_normpath(
Expand Down
2 changes: 1 addition & 1 deletion pyfakefs/fake_filesystem_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ class Patcher:
FS_DEFARGS: List[Tuple[FunctionType, int, Callable[..., Any]]] = []
SKIPPED_FS_MODULES: Dict[str, Set[Tuple[ModuleType, str]]] = {}

assert None in SKIPMODULES, "sys.modules contains 'None' values;" " must skip them."
assert None in SKIPMODULES, "sys.modules contains 'None' values; must skip them."

IS_WINDOWS = sys.platform in ("win32", "cygwin")

Expand Down
7 changes: 3 additions & 4 deletions pyfakefs/fake_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,7 @@ def _path_with_dir_fd(
raise NotImplementedError("dir_fd unavailable on this platform")
if isinstance(path, int):
raise ValueError(
"%s: Can't specify dir_fd without "
"matching path_str" % fct.__name__
"%s: Can't specify dir_fd without matching path_str" % fct.__name__
)
if not self.path.isabs(path):
open_file = self.filesystem.get_open_file(dir_fd)
Expand Down Expand Up @@ -1068,7 +1067,7 @@ def fchmod(
"""
if self.filesystem.is_windows_fs and sys.version_info < (3, 13):
raise AttributeError(
"module 'os' has no attribute 'fchmod'. " "Did you mean: 'chmod'?"
"module 'os' has no attribute 'fchmod'. Did you mean: 'chmod'?"
)
self.filesystem.chmod(fd, mode)

Expand All @@ -1094,7 +1093,7 @@ def chmod(
self.chmod not in self.supports_follow_symlinks or IS_PYPY
):
raise NotImplementedError(
"`follow_symlinks` for chmod() is not available " "on this system"
"`follow_symlinks` for chmod() is not available on this system"
)
path = self._path_with_dir_fd(path, self.chmod, dir_fd)
self.filesystem.chmod(path, mode, follow_symlinks)
Expand Down
2 changes: 1 addition & 1 deletion pyfakefs/fake_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def realpath(self, filename: AnyStr, strict: Optional[bool] = None) -> AnyStr:
symbolic links encountered in the path.
"""
if strict is not None and sys.version_info < (3, 10):
raise TypeError("realpath() got an unexpected " "keyword argument 'strict'")
raise TypeError("realpath() got an unexpected keyword argument 'strict'")
if strict:
# raises in strict mode if the file does not exist
self.filesystem.resolve(filename)
Expand Down
14 changes: 6 additions & 8 deletions pyfakefs/fake_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ def chmod(self, pathobj, *args, **kwargs):
if "follow_symlinks" in kwargs:
if sys.version_info < (3, 10):
raise TypeError(
"chmod() got an unexpected keyword " "argument 'follow_symlinks'"
"chmod() got an unexpected keyword argument 'follow_symlinks'"
)

if not kwargs["follow_symlinks"] and (
os.chmod not in os.supports_follow_symlinks or IS_PYPY
):
raise NotImplementedError(
"`follow_symlinks` for chmod() is not available " "on this system"
"`follow_symlinks` for chmod() is not available on this system"
)
return pathobj.filesystem.chmod(str(pathobj), *args, **kwargs)

Expand Down Expand Up @@ -432,7 +432,7 @@ def gethomedir(self, username):
return pwd.getpwnam(username).pw_dir
except KeyError:
raise RuntimeError(
"Can't determine home directory " "for %r" % username
"Can't determine home directory for %r" % username
)

class _FakeWindowsFlavour(_FakeFlavour):
Expand Down Expand Up @@ -502,7 +502,7 @@ def gethomedir(self, username):
drv, root, parts = self.parse_parts((userhome,))
if parts[-1] != os.environ["USERNAME"]:
raise RuntimeError(
"Can't determine home directory " "for %r" % username
"Can't determine home directory for %r" % username
)
parts[-1] = username
if drv or root:
Expand Down Expand Up @@ -549,7 +549,7 @@ def gethomedir(self, username):
return pwd.getpwnam(username).pw_dir
except KeyError:
raise RuntimeError(
"Can't determine home directory " "for %r" % username
"Can't determine home directory for %r" % username
)

def compile_pattern(self, pattern):
Expand Down Expand Up @@ -765,9 +765,7 @@ def write_text(self, data, encoding=None, errors=None, newline=None):
if not isinstance(data, str):
raise TypeError("data must be str, not %s" % data.__class__.__name__)
if newline is not None and sys.version_info < (3, 10):
raise TypeError(
"write_text() got an unexpected " "keyword argument 'newline'"
)
raise TypeError("write_text() got an unexpected keyword argument 'newline'")
with fake_open(
self.filesystem,
self.skip_names,
Expand Down
2 changes: 1 addition & 1 deletion pyfakefs/fake_scandir.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def __init__(self, filesystem, path):
if isinstance(path, int):
if self.filesystem.is_windows_fs:
raise NotImplementedError(
"scandir does not support file descriptor " "path argument"
"scandir does not support file descriptor path argument"
)
self.abspath = self.filesystem.absnormpath(
self.filesystem.get_open_file(path).get_object().path
Expand Down
4 changes: 2 additions & 2 deletions pyfakefs/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def st_blocks(self) -> int:
def st_file_attributes(self) -> int:
if not self.is_windows:
raise AttributeError(
"module 'os.stat_result' " "has no attribute 'st_file_attributes'"
"module 'os.stat_result' has no attribute 'st_file_attributes'"
)
mode = 0
st_mode = self.st_mode
Expand All @@ -385,7 +385,7 @@ def st_file_attributes(self) -> int:
def st_reparse_tag(self) -> int:
if not self.is_windows or sys.version_info < (3, 8):
raise AttributeError(
"module 'os.stat_result' " "has no attribute 'st_reparse_tag'"
"module 'os.stat_result' has no attribute 'st_reparse_tag'"
)
if self.st_mode & stat.S_IFLNK:
return stat.IO_REPARSE_TAG_SYMLINK # type: ignore[attr-defined]
Expand Down
2 changes: 1 addition & 1 deletion pyfakefs/tests/example_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_create_file(self):

def test_delete_file(self):
"""Test example.delete_file() which uses `os.remove()`."""
self.fs.create_file("/test/full.txt", contents="First line\n" "Second Line\n")
self.fs.create_file("/test/full.txt", contents="First line\nSecond Line\n")
self.assertTrue(os.path.exists("/test/full.txt"))
example.delete_file("/test/full.txt")
self.assertFalse(os.path.exists("/test/full.txt"))
Expand Down
6 changes: 3 additions & 3 deletions pyfakefs/tests/fake_filesystem_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ def test_getattr_forward_to_real_os_path(self):
if private_path_function:
self.assertTrue(
hasattr(self.path, private_path_function),
"Get a real os.path function " "not implemented in fake os.path",
"Get a real os.path function not implemented in fake os.path",
)
self.assertFalse(hasattr(self.path, "nonexistent"))

Expand Down Expand Up @@ -1771,7 +1771,7 @@ def test_creating_file_with_fitting_content(self):
self.fs.create_file("!foo!bar", contents=b"a" * 100)
except OSError:
self.fail(
"File with contents fitting into disk space " "could not be written."
"File with contents fitting into disk space could not be written."
)

self.assertEqual(initial_usage.used + 100, self.fs.get_disk_usage().used)
Expand Down Expand Up @@ -1863,7 +1863,7 @@ def test_that_the_size_of_correct_mount_point_is_used(self):
self.fs.create_file("!mount_unlimited!foo", st_size=1000000)
except OSError:
self.fail(
"File with contents fitting into " "disk space could not be written."
"File with contents fitting into disk space could not be written."
)

def test_that_disk_usage_of_correct_mount_point_is_used(self):
Expand Down
6 changes: 3 additions & 3 deletions pyfakefs/tests/fake_filesystem_unittest_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,20 @@ def test_open(self):
with open("/fake_file.txt", encoding="utf8") as f:
content = f.read()
self.assertEqual(
"This test file was created using the " "open() function.\n",
"This test file was created using the open() function.\n",
content,
)

def test_io_open(self):
"""Fake io module is bound"""
self.assertFalse(os.path.exists("/fake_file.txt"))
with io_open("/fake_file.txt", "w", encoding="utf8") as f:
f.write("This test file was created using the" " io.open() function.\n")
f.write("This test file was created using the io.open() function.\n")
self.assertTrue(self.fs.exists("/fake_file.txt"))
with open("/fake_file.txt", encoding="utf8") as f:
content = f.read()
self.assertEqual(
"This test file was created using the " "io.open() function.\n",
"This test file was created using the io.open() function.\n",
content,
)

Expand Down
6 changes: 3 additions & 3 deletions pyfakefs/tests/fake_open_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def test_overwrite_existing_file(self):
def test_append_existing_file(self):
file_path = self.make_path("appendfile")
contents = [
"Contents of original file" "Appended contents",
"Contents of original fileAppended contents",
]

self.create_file(file_path, contents=contents[0])
Expand Down Expand Up @@ -1445,7 +1445,7 @@ def test_write_and_read_str(self):

def test_create_file_with_append(self):
contents = [
"Allons enfants de la Patrie," "Le jour de gloire est arrivé!",
"Allons enfants de la Patrie,Le jour de gloire est arrivé!",
"Contre nous de la tyrannie,",
"L’étendard sanglant est levé.",
]
Expand All @@ -1458,7 +1458,7 @@ def test_create_file_with_append(self):

def test_append_existing_file(self):
contents = [
"Оригинальное содержание" "Дополнительное содержание",
"Оригинальное содержаниеДополнительное содержание",
]
self.create_file(self.file_path, contents=contents[0], encoding="cyrillic")
with self.open(self.file_path, "a", encoding="cyrillic") as fake_file:
Expand Down
2 changes: 1 addition & 1 deletion pyfakefs/tests/fake_os_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4792,7 +4792,7 @@ def test_walk_calls_on_error_if_non_existent(self):
def test_walk_calls_on_error_if_not_directory(self):
"""Calls onerror with correct errno when walking non-directory."""
self.ResetErrno()
filename = self.make_path("foo" "bar")
filename = self.make_path("foobar")
self.create_file(filename)
self.assertEqual(True, self.os.path.exists(filename))
# Calling `os.walk` on a file should trigger a call to the
Expand Down

0 comments on commit 04771e7

Please sign in to comment.