Skip to content

Commit

Permalink
Add isort to pre-commit configuration
Browse files Browse the repository at this point in the history
Also run it on all files.
  • Loading branch information
ronaldoussoren committed Apr 10, 2022
1 parent b785157 commit 03bc5ab
Show file tree
Hide file tree
Showing 66 changed files with 229 additions and 198 deletions.
9 changes: 8 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
repos:
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
hooks:
- id: isort
additional_dependencies: [toml]
language_version: python3.9

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
Expand All @@ -9,7 +16,7 @@ repos:
types: []

- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
rev: v2.32.0
hooks:
- id: pyupgrade
args: ['--py36-plus']
Expand Down
2 changes: 2 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ py2app.0.29

* #426: Remove code that supports Python 3.5 or earlier

* Add 'isort' to pre-commit configuration

py2app 0.28
-----------

Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import sys


def get_version():
Expand Down
2 changes: 1 addition & 1 deletion examples/EggInstaller/EggInstaller.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import sys
import time
import tempfile
import time

SCRIPT = """#!%s
import os
Expand Down
3 changes: 2 additions & 1 deletion examples/PIL/hello.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import os
import sys

import PIL.Image

PATH = "/System/Library//Automator/Crop Images.action/Contents/Resources/shark-tall-no-scale.jpg"
Expand Down
3 changes: 1 addition & 2 deletions examples/PyObjC/ICSharingWatcher/ICSharingWatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
Internet Connection Sharing
"""

from PyObjCTools import AppHelper

# import classes required to start application
import TableModelAppDelegate # noqa: F401
from PyObjCTools import AppHelper

# start the event loop
AppHelper.runEventLoop(argv=[], installInterrupt=False)
5 changes: 3 additions & 2 deletions examples/PyObjC/ICSharingWatcher/TableModelAppDelegate.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
from Cocoa import NSObject, NSTimer, NSApp
import objc

import leases
import objc
from Cocoa import NSApp, NSObject, NSTimer

FILENAME = "/var/db/dhcpd_leases"

Expand Down
5 changes: 3 additions & 2 deletions examples/PyObjC/TinyTinyEdit/TinyTinyEdit.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""TinyTinyEdit -- A minimal Document-based Cocoa application."""

import sys

import objc
from Cocoa import NSDocument
from PyObjCTools import AppHelper
import objc
import sys

try:
unicode
Expand Down
5 changes: 3 additions & 2 deletions examples/PyObjC/pbplugin/PyTestPlugin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from Foundation import NSObject
import objc
import sys

import objc
from Foundation import NSObject


class PyTestPlugin(NSObject):
"""docstring"""
Expand Down
3 changes: 2 additions & 1 deletion examples/PyObjC/pbplugin/test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import sys

import objc
from Foundation import NSBundle, NSLog
import sys

old_path = set(sys.path)
old_modules = set(sys.modules)
Expand Down
3 changes: 2 additions & 1 deletion examples/PyQt/cython_app/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import testLoad
from logging import basicConfig # noqa: F401

import testLoad


def main():
testLoad.main()
Expand Down
3 changes: 1 addition & 2 deletions examples/PyQt/cython_app/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
dependency.
"""

from setuptools import setup
from Cython.Build import cythonize
from Cython.Distutils import build_ext

from setuptools import setup

setup(
name="test",
Expand Down
1 change: 1 addition & 0 deletions examples/PyQt/hello_app/hello.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys

from PyQt5 import Qt

# We instantiate a QApplication passing the arguments of the script to it:
Expand Down
2 changes: 1 addition & 1 deletion examples/PyQt/view_app/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from PyQt4.QtCore import QUrl
from PyQt4.QtGui import QApplication
from PyQt4.QtDeclarative import QDeclarativeView
from PyQt4.QtGui import QApplication

# This example uses a QML file to show a scrolling list containing
# all the items listed into dataList.
Expand Down
1 change: 1 addition & 0 deletions examples/PySide/hello.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys

from PySide import QtGui

# We instantiate a QApplication passing the arguments of the script to it:
Expand Down
2 changes: 1 addition & 1 deletion examples/embedded_interpreter/simple/hello.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
import os
import sys


def print_sys():
Expand Down
2 changes: 1 addition & 1 deletion examples/multiprocessing/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import multiprocessing
from proc import main

from proc import main

if __name__ == "__main__":
multiprocessing.freeze_support()
Expand Down
4 changes: 2 additions & 2 deletions examples/pygame/aliens.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env python

import random
import os.path
import random

# import basic pygame modules
import pygame
from pygame.locals import Rect, Color, QUIT, KEYDOWN, K_ESCAPE, K_RIGHT, K_LEFT, K_SPACE
from pygame.locals import K_ESCAPE, K_LEFT, K_RIGHT, K_SPACE, KEYDOWN, QUIT, Color, Rect

# see if we can load more than standard BMP
if not pygame.image.get_extended():
Expand Down
6 changes: 3 additions & 3 deletions examples/pygame/aliens_bootstrap.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from AppKit import NSTerminateNow, NSApp, NSRunAlertPanel
from AppKit import NSApp, NSRunAlertPanel, NSTerminateNow
from Foundation import NSObject
from PyObjCTools import AppHelper


def exception_handler():
import traceback
import sys
import os
import sys
import traceback

typ, info, trace = sys.exc_info()
if typ in (KeyboardInterrupt, SystemExit):
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/hello.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import os
import pprint
import sys

print(__file__)

Expand Down
9 changes: 4 additions & 5 deletions examples/wxPython/2.4/doodle/superdoodle.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
implemented using an wx.html.HtmlWindow.
"""

import wx # This module uses the new wx namespace
import wx.html
from wx.lib import buttons # for generic button classes
from doodle import DoodleWindow

import os
import pickle

import wx # This module uses the new wx namespace
import wx.html
from doodle import DoodleWindow
from wx.lib import buttons # for generic button classes

# ----------------------------------------------------------------------

Expand Down
9 changes: 4 additions & 5 deletions examples/wxPython/2.5/doodle/superdoodle.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
implemented using an wx.html.HtmlWindow.
"""

import wx # This module uses the new wx namespace
import wx.html
from wx.lib import buttons # for generic button classes
from doodle import DoodleWindow

import os
import pickle

import wx # This module uses the new wx namespace
import wx.html
from doodle import DoodleWindow
from wx.lib import buttons # for generic button classes

# ----------------------------------------------------------------------

Expand Down
3 changes: 2 additions & 1 deletion examples/wxPython/2.5/drpython/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
Usage:
python setup.py py2app
"""
from setuptools import setup
import os

from setuptools import setup

VERSION = "3.10.1"
PATH = f"drpython-{VERSION}"
script = []
Expand Down
3 changes: 2 additions & 1 deletion examples/wxPython/2.5/wxGlade/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
Usage:
python setup.py py2app
"""
from setuptools import setup
import glob
import os
import sys

from setuptools import setup

NAME = "wxGlade"
VERSION = "0.3.4"
WXDIR = f"{NAME}-{VERSION}"
Expand Down
5 changes: 3 additions & 2 deletions examples/wxPython/2.5/wxGlade/wxGlade.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os
import sys
import wxglade
import common
import webbrowser

import common
import main
import wxglade

common.wxglade_path = os.getcwd()

Expand Down
9 changes: 4 additions & 5 deletions examples/wxPython/4.0/doodle/superdoodle.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
implemented using an wx.html.HtmlWindow.
"""

import wx # This module uses the new wx namespace
import wx.html
from wx.lib import buttons # for generic button classes
from doodle import DoodleWindow

import os
import pickle as cPickle

import wx # This module uses the new wx namespace
import wx.html
from doodle import DoodleWindow
from wx.lib import buttons # for generic button classes

# ----------------------------------------------------------------------

Expand Down
1 change: 0 additions & 1 deletion py2app/apptemplate/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
import re


gPreBuildVariants = [
{
"name": "main-universal2",
Expand Down
2 changes: 1 addition & 1 deletion py2app/build_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""

import collections
import zlib
import imp
import os
import plistlib
Expand All @@ -14,6 +13,7 @@
import sys
import types
import zipfile
import zlib
from distutils import log
from distutils.errors import DistutilsOptionError, DistutilsPlatformError
from distutils.sysconfig import get_config_h_filename, get_config_var
Expand Down
1 change: 0 additions & 1 deletion py2app/bundletemplate/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import os
import re


gPreBuildVariants = [
{
"name": "main-universal2",
Expand Down
1 change: 0 additions & 1 deletion py2app/recipes/setuptools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import sys
import textwrap

from io import StringIO

PRESCRIPT = textwrap.dedent(
Expand Down
2 changes: 1 addition & 1 deletion py2app_tests/app_with_email/main-compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@


def function():
from email import MIMEText # noqa: F401
import email.Encoders as enc # noqa: F401
from email import MIMEText # noqa: F401


function()
Expand Down
2 changes: 1 addition & 1 deletion py2app_tests/app_with_email/main-plain.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import sys
import email # noqa: F401
import sys


def import_module(name):
Expand Down
3 changes: 1 addition & 2 deletions py2app_tests/app_with_environment/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys
import os

import sys

root = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
Expand Down
12 changes: 6 additions & 6 deletions py2app_tests/app_with_scripts/presetup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from distutils.core import setup, Extension, Command
from distutils import sysconfig
from distutils.command.build_ext import build_ext
from distutils.version import LooseVersion
import os
import shutil
import platform
import re
import shutil
import subprocess
import platform
from distutils import sysconfig
from distutils.command.build_ext import build_ext
from distutils.core import Command, Extension, setup
from distutils.version import LooseVersion


class my_build_ext(build_ext):
Expand Down
1 change: 1 addition & 0 deletions py2app_tests/app_with_scripts/subdir/helper2.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import code # noqa: F401

import foo

print(f"Helper 2: {foo.sq_2}")
Loading

0 comments on commit 03bc5ab

Please sign in to comment.