Remove unneeded str

Only needed in Python 3.5 times
This commit is contained in:
Florian Bruhin 2022-09-30 20:15:27 +02:00
parent 8c02ef69ec
commit fa62360357
10 changed files with 17 additions and 17 deletions

View File

@ -73,7 +73,7 @@ class AsciiDoc:
def cleanup(self) -> None:
"""Clean up the temporary home directory for asciidoc."""
if self._homedir is not None and not self._failed:
shutil.rmtree(str(self._homedir))
shutil.rmtree(self._homedir)
def build(self) -> None:
"""Build either the website or the docs."""
@ -119,7 +119,7 @@ class AsciiDoc:
for filename in ['cheatsheet-big.png', 'cheatsheet-small.png']:
src = REPO_ROOT / 'doc' / 'img' / filename
dst = dst_path / filename
shutil.copy(str(src), str(dst))
shutil.copy(src, dst)
def _build_website_file(self, root: pathlib.Path, filename: str) -> None:
"""Build a single website file."""
@ -131,7 +131,7 @@ class AsciiDoc:
assert self._tempdir is not None # for mypy
modified_src = self._tempdir / src.name
shutil.copy(str(REPO_ROOT / 'www' / 'header.asciidoc'), modified_src)
shutil.copy(REPO_ROOT / 'www' / 'header.asciidoc', modified_src)
outfp = io.StringIO()

View File

@ -64,7 +64,7 @@ def _get_files(
continue
try:
with tokenize.open(str(path)):
with tokenize.open(path):
pass
except SyntaxError as e:
# Could not find encoding
@ -274,7 +274,7 @@ def check_spelling(args: argparse.Namespace) -> Optional[bool]:
try:
ok = True
for path in _get_files(verbose=args.verbose, ignored=ignored):
with tokenize.open(str(path)) as f:
with tokenize.open(path) as f:
if not _check_spelling_file(path, f, patterns):
ok = False
print()
@ -292,7 +292,7 @@ def check_vcs_conflict(args: argparse.Namespace) -> Optional[bool]:
if path.suffix in {'.rst', '.asciidoc'}:
# False positives
continue
with tokenize.open(str(path)) as f:
with tokenize.open(path) as f:
for line in f:
if any(line.startswith(c * 7) for c in '<>=|'):
print("Found conflict marker in {}".format(path))

View File

@ -180,7 +180,7 @@ def delete_old_venv(venv_dir: pathlib.Path) -> None:
'remove it.'.format(venv_dir))
print_command('rm -r', venv_dir, venv=False)
shutil.rmtree(str(venv_dir))
shutil.rmtree(venv_dir)
def create_venv(venv_dir: pathlib.Path, use_virtualenv: bool = False) -> None:

View File

@ -38,7 +38,7 @@ def download_dir(tmpdir):
downloads.ensure(dir=True)
(downloads / 'subdir').ensure(dir=True)
try:
os.mkfifo(str(downloads / 'fifo'))
os.mkfifo(downloads / 'fifo')
except AttributeError:
pass
unwritable = downloads / 'unwritable'
@ -72,7 +72,7 @@ def check_ssl():
@bdd.when("the unwritable dir is unwritable")
def check_unwritable(tmpdir):
unwritable = tmpdir / 'downloads' / 'unwritable'
if os.access(str(unwritable), os.W_OK):
if os.access(unwritable, os.W_OK):
# Docker container or similar
pytest.skip("Unwritable dir was writable")
@ -166,4 +166,4 @@ def delete_file(tmpdir, filename):
def fifo_should_be_fifo(tmpdir):
download_dir = tmpdir / 'downloads'
assert download_dir.exists()
assert not os.path.isfile(str(download_dir / 'fifo'))
assert not os.path.isfile(download_dir / 'fifo')

View File

@ -717,7 +717,7 @@ def state_config(data_tmpdir, monkeypatch):
@pytest.fixture
def unwritable_tmp_path(tmp_path):
tmp_path.chmod(0)
if os.access(str(tmp_path), os.W_OK):
if os.access(tmp_path, os.W_OK):
# Docker container or similar
pytest.skip("Directory was still writable")

View File

@ -224,11 +224,11 @@ def nop_contextmanager():
def change_cwd(path):
"""Use a path as current working directory."""
old_cwd = pathlib.Path.cwd()
os.chdir(str(path))
os.chdir(path)
try:
yield
finally:
os.chdir(str(old_cwd))
os.chdir(old_cwd)
@contextlib.contextmanager

View File

@ -178,7 +178,7 @@ def unreadable_file(tmpdir):
unreadable_file = tmpdir / 'unreadable'
unreadable_file.ensure()
unreadable_file.chmod(0)
if os.access(str(unreadable_file), os.R_OK):
if os.access(unreadable_file, os.R_OK):
# Docker container or similar
pytest.skip("File was still readable")

View File

@ -48,7 +48,7 @@ def test_get_file_list(tmpdir, create_file, create_dir, filterfunc, expected):
if create_file or create_dir:
path.ensure(dir=create_dir)
all_files = os.listdir(str(tmpdir))
all_files = os.listdir(tmpdir)
result = filescheme.get_file_list(str(tmpdir), all_files, filterfunc)
item = {'name': 'foo', 'absname': str(path)}

View File

@ -505,7 +505,7 @@ class TestYaml:
def unreadable_autoconfig(self, autoconfig):
autoconfig.fobj.ensure()
autoconfig.fobj.chmod(0)
if os.access(str(autoconfig.fobj), os.R_OK):
if os.access(autoconfig.fobj, os.R_OK):
# Docker container or similar
pytest.skip("File was still readable")

View File

@ -128,7 +128,7 @@ class TestFileHandling:
filename = pathlib.Path(editor._filename)
assert filename.exists()
filename.chmod(0o277)
if os.access(str(filename), os.R_OK):
if os.access(filename, os.R_OK):
# Docker container or similar
pytest.skip("File was still readable")