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] committed Sep 25, 2023
1 parent 41842bf commit 6fa2593
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 40 deletions.
1 change: 0 additions & 1 deletion examples/pygame/aliens.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ def main(winstyle=0):
all.add(Score())

while player.alive():

# get input
for event in pygame.event.get():
if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE):
Expand Down
6 changes: 3 additions & 3 deletions py2app_tests/test_app_with_ctypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def setUpClass(cls):
print(lines)
try:
os.waitpid(0, 0)
except os.error:
except OSError:
pass

raise AssertionError("Running sharedlib failed")
Expand All @@ -72,13 +72,13 @@ def setUpClass(cls):
print(lines)
try:
os.waitpid(0, 0)
except os.error:
except OSError:
pass
raise AssertionError("Creating basic_app bundle failed")

try:
os.waitpid(0, 0)
except os.error:
except OSError:
pass

@classmethod
Expand Down
6 changes: 3 additions & 3 deletions py2app_tests/test_app_with_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def setUpClass(cls):
print("Creating basic_app extension failed")
try:
os.waitpid(0, 0)
except os.error:
except OSError:
pass
raise AssertionError("Creating basic_app extension failed")

Expand All @@ -114,13 +114,13 @@ def setUpClass(cls):
print("Creating basic_app bundle failed")
try:
os.waitpid(0, 0)
except os.error:
except OSError:
pass
raise AssertionError("Creating basic_app bundle failed")

try:
os.waitpid(0, 0)
except os.error:
except OSError:
pass

cls.checksums = make_checksums(os.path.join(cls.app_dir, "dist/BasicApp.app"))
Expand Down
8 changes: 4 additions & 4 deletions py2app_tests/test_basic_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def setUpClass(cls):
print(lines)
try:
os.waitpid(0, 0)
except os.error:
except OSError:
pass
raise AssertionError("Creating basic_plugin bundle failed")

Expand All @@ -72,7 +72,7 @@ def setUpClass(cls):
if p.wait() != 0:
try:
os.waitpid(0, 0)
except os.error:
except OSError:
pass
raise AssertionError("Fetching Xcode root failed")

Expand Down Expand Up @@ -103,13 +103,13 @@ def setUpClass(cls):
print(lines)
try:
os.waitpid(0, 0)
except os.error:
except OSError:
pass
raise AssertionError("Creating bundle_loader failed")

try:
os.waitpid(0, 0)
except os.error:
except OSError:
pass

except: # noqa: E722, B001
Expand Down
1 change: 0 additions & 1 deletion py2app_tests/test_recipe_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@ def test_imports(self):
pass

else:

self.fail(f"Can import {mod!r}")
2 changes: 0 additions & 2 deletions py2app_tests/test_setuptools_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ def test_target_not_list(self):
errors.DistutilsOptionError,
"target definition should be a sequence: 42",
):

self.run_setuptools(
commandline_options=["setup.py", "py2app2"],
setup_keywords={kind: 42},
Expand All @@ -441,7 +440,6 @@ def test_target_entry_invalid(self):
with self.assertRaisesRegex(
errors.DistutilsOptionError, "42 is not a valid target definition"
):

self.run_setuptools(
commandline_options=["setup.py", "py2app2"],
setup_keywords={kind: [42]},
Expand Down
6 changes: 3 additions & 3 deletions py2app_tests/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def kill_child_processes():
continue
try:
os.kill(int(pid), sig)
except os.error:
except OSError:
pass

ps_command = subprocess.Popen("ps -ax", shell=True, stdout=subprocess.PIPE)
Expand All @@ -33,10 +33,10 @@ def kill_child_processes():
pid, _ = line.split(None, 1)
try:
os.kill(int(pid), sig)
except os.error:
except OSError:
pass

try:
os.waitpid(0, 0)
except os.error:
except OSError:
pass
1 change: 0 additions & 1 deletion src/py2app/_setuptools_stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def fancy_split(name: str, s: typing.Any) -> typing.List[str]:
def fixup_targets(
targets: typing.Sequence[typing.Union[str, _ScriptInfo]],
) -> typing.Sequence[_ScriptInfo]:

if targets is None:
return []

Expand Down
2 changes: 1 addition & 1 deletion src/py2app/apptemplate/lib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def addsitedir(sitedir: str) -> None:
sys.path.append(sitedir) # Add path component
try:
names = os.listdir(sitedir)
except os.error:
except OSError:
return
names.sort()
for name in names:
Expand Down
1 change: 0 additions & 1 deletion src/py2app/bootstrap/argv_emulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def _ctypes_setup() -> ctypes.CDLL:


def _run_argvemulator(timeout: float = 60.0) -> None:

# Configure ctypes
carbon = _ctypes_setup()

Expand Down
1 change: 0 additions & 1 deletion src/py2app/bootstrap/setup_included_subpackages.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ def _included_subpackages(packages: "list[str]") -> None:

class Loader:
def load_module(self, fullname: str) -> types.ModuleType:

pkg_dir = os.path.join(
os.environ["RESOURCEPATH"], "lib", "python%d.%d" % (sys.version_info[:2])
)
Expand Down
1 change: 0 additions & 1 deletion src/py2app/bootstrap/setup_pkgresource.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ def _setup_pkgresources() -> None:
resource_path = os.getenv("RESOURCEPATH")
assert resource_path is not None
with open(os.path.join(os.path.dirname(resource_path), "Info.plist"), "rb") as fp:

pl = plistlib.load(fp)

appname = pl.get("CFBundleIdentifier")
Expand Down
22 changes: 9 additions & 13 deletions src/py2app/build_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,13 @@ def copy_framework(self, info: _FrameworkInfo) -> str:
return destfn


def iter_recipes() -> typing.Iterator[
typing.Tuple[
str, typing.Callable[["py2app", ModuleGraph], typing.Optional[RecipeInfo]]
def iter_recipes() -> (
typing.Iterator[
typing.Tuple[
str, typing.Callable[["py2app", ModuleGraph], typing.Optional[RecipeInfo]]
]
]
]:
):
for name in dir(recipes):
if name.startswith("_"):
continue
Expand Down Expand Up @@ -697,7 +699,6 @@ def finalize_options(self) -> None:
if not self.plist:
self.plist = {}
if isinstance(self.plist, str):

with open(self.plist, "rb") as fp:
self.plist = plistlib.load(fp)

Expand Down Expand Up @@ -908,9 +909,7 @@ def run(self) -> None:
def iter_datamodels(
self, resdir: typing.Union[str, os.PathLike[str]]
) -> typing.Iterator[typing.Tuple[str, str]]:
for (path, files) in (
normalize_data_file(fn) for fn in (self.datamodels or ())
):
for path, files in (normalize_data_file(fn) for fn in (self.datamodels or ())):
for fn in files:
basefn, ext = os.path.splitext(fn)
if ext != ".xcdatamodel":
Expand All @@ -928,7 +927,7 @@ def compile_datamodels(self, resdir: typing.Union[str, os.PathLike[str]]) -> Non
def iter_mappingmodels(
self, resdir: typing.Union[str, os.PathLike[str]]
) -> typing.Iterator[typing.Tuple[str, str]]:
for (path, files) in (
for path, files in (
normalize_data_file(fn) for fn in (self.mappingmodels or ())
):
for fn in files:
Expand Down Expand Up @@ -968,7 +967,7 @@ def iter_extra_plugins(self) -> typing.Iterator[typing.Tuple[str, str]]:
def iter_data_files(self) -> typing.Iterator[typing.Tuple[str, str]]:
dist = self.distribution
allres = chain(getattr(dist, "data_files", ()) or (), self.resources)
for (path, files) in (normalize_data_file(fn) for fn in allres):
for path, files in (normalize_data_file(fn) for fn in allres):
for fn in files:
assert isinstance(fn, str)
yield fn, os.path.join(path, os.path.basename(fn))
Expand Down Expand Up @@ -2085,7 +2084,6 @@ def initialize_prescripts(self) -> None:
real_prefix = None
global_site_packages = False
with open(os.path.join(sys.prefix, "pyvenv.cfg")) as fp:

for ln in fp:
if ln.startswith("home = "):
_, home_path = ln.split("=", 1)
Expand Down Expand Up @@ -2172,7 +2170,6 @@ def initialize_prescripts(self) -> None:
prescripts.append("disable_linecache")
prescripts.append("boot_" + self.style)
else:

# Add ctypes prescript because it is needed to
# find libraries in the bundle, but we don't run
# recipes and hence the ctypes recipe is not used
Expand Down Expand Up @@ -2385,7 +2382,6 @@ def copy_loader_paths(
sourcefn: typing.Union[str, os.PathLike[str]],
destfn: typing.Union[str, os.PathLike[str]],
) -> None:

todo = [(sourcefn, destfn)]

while todo:
Expand Down
2 changes: 1 addition & 1 deletion src/py2app/bundletemplate/lib/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def addsitedir(sitedir: str) -> None:
sys.path.append(sitedir) # Add path component
try:
names = os.listdir(sitedir)
except os.error:
except OSError:
return
names.sort()
for name in names:
Expand Down
3 changes: 1 addition & 2 deletions src/py2app/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,6 @@ def copy_tree(
condition: typing.Optional[typing.Callable[[str], bool]] = None,
progress: typing.Optional[Progress] = None,
) -> typing.List[str]:

"""
Copy an entire directory tree 'src' to a new location 'dst'. Both
'src' and 'dst' must be directory names. If 'src' is not a
Expand Down Expand Up @@ -525,7 +524,7 @@ def copy_tree(
raise DistutilsFileError("cannot copy tree '%s': not a directory" % src)
try:
names = zipio.listdir(src)
except os.error as exc:
except OSError as exc:
(errno, errstr) = exc.args
if dry_run:
names = []
Expand Down
1 change: 1 addition & 0 deletions stubs/macholib/MachOGraph.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import typing

from .MachO import MachO

class MachOGraph:
Expand Down
3 changes: 2 additions & 1 deletion stubs/macholib/MachOStandalone.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" """
import typing
import collections
import typing

from macholib.MachOGraph import MachOGraph

class MachOStandalone:
Expand Down
3 changes: 2 additions & 1 deletion stubs/modulegraph/find_modules.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
""" """
import typing
from .modulegraph import Node, Extension, ModuleGraph

from .modulegraph import Extension, ModuleGraph, Node

PY_SUFFIXES: list[str]
C_SUFFIXES: list[str]
Expand Down

0 comments on commit 6fa2593

Please sign in to comment.