Skip to content

Commit

Permalink
QA: Apply isort suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Nov 20, 2023
1 parent 1a599df commit 02d64d1
Show file tree
Hide file tree
Showing 24 changed files with 56 additions and 46 deletions.
3 changes: 2 additions & 1 deletion examples/7color/advanced/dither.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import sys

import hitherdither
from inky import auto
from PIL import Image

from inky import auto

print("""dither.py
Advanced dithering example using Hitherdither by Henrik Blidh:
Expand Down
1 change: 1 addition & 0 deletions examples/7color/buttons.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

import signal

import RPi.GPIO as GPIO

print("""buttons.py - Detect which button has been pressed
Expand Down
3 changes: 2 additions & 1 deletion examples/7color/colour-palette.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#!/usr/bin/env python3

from inky.inky_uc8159 import Inky
import argparse
import pathlib
import struct
import sys

from inky.inky_uc8159 import Inky

parser = argparse.ArgumentParser()

parser.add_argument('--type', '-t', choices=['css', 'act', 'raw', 'pal', 'gpl'], help='Type of palette to output')
Expand Down
7 changes: 4 additions & 3 deletions examples/7color/graph.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env python3

import argparse
import io

import seaborn
from matplotlib import pyplot
from PIL import Image

from inky.auto import auto
from matplotlib import pyplot
import seaborn
import argparse

print("""
Expand Down
3 changes: 2 additions & 1 deletion examples/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import argparse
import time

from inky.auto import auto
from PIL import Image

from inky.auto import auto

print("""Inky pHAT: Clean
Displays solid blocks of red, black, and white to clean the Inky pHAT
Expand Down
3 changes: 2 additions & 1 deletion examples/logo.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env python3

import os

from PIL import Image
from inky.auto import auto

from inky.auto import auto

print("""Inky pHAT/wHAT: Logo
Expand Down
4 changes: 2 additions & 2 deletions examples/name-badge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import argparse

from PIL import Image, ImageFont, ImageDraw
from font_hanken_grotesk import HankenGroteskBold, HankenGroteskMedium
from font_intuitive import Intuitive
from inky.auto import auto
from PIL import Image, ImageDraw, ImageFont

from inky.auto import auto

print("""Inky pHAT/wHAT: Hello... my name is:
Expand Down
3 changes: 2 additions & 1 deletion examples/phat/calendar-phat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import datetime
import os

from inky.auto import auto
from PIL import Image, ImageDraw

from inky.auto import auto

print("""Inky pHAT: Calendar
Draws a calendar for the current month to your Inky pHAT.
Expand Down
5 changes: 3 additions & 2 deletions examples/phat/weather-phat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
# -*- coding: utf-8 -*-

import glob
import json
import os
import time
import json
from sys import exit

from font_fredoka_one import FredokaOne
from inky.auto import auto
from PIL import Image, ImageDraw, ImageFont

from inky.auto import auto

"""
To run this example on Python 2.x you should:
sudo apt install python-lxml
Expand Down
4 changes: 3 additions & 1 deletion examples/tests/border.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env python3
import time
import sys
import time

from PIL import Image

from inky import InkyPHAT

INKY_COLOUR = None
Expand Down
2 changes: 2 additions & 0 deletions examples/what/dither-image-what.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env python3

import argparse

from PIL import Image

from inky.auto import auto

print("""Inky wHAT: Dither image
Expand Down
8 changes: 4 additions & 4 deletions examples/what/quotes-what.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import random
import sys

from inky.auto import auto

from PIL import Image, ImageFont, ImageDraw
from font_source_serif_pro import SourceSerifProSemibold
from font_source_sans_pro import SourceSansProSemibold
from font_source_serif_pro import SourceSerifProSemibold
from PIL import Image, ImageDraw, ImageFont

from inky.auto import auto

print("""Inky wHAT: Quotes
Expand Down
16 changes: 8 additions & 8 deletions inky/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""Inky e-Ink Display Drivers."""

from . import inky # noqa: F401
from .inky import BLACK, WHITE, RED, YELLOW # noqa: F401
from .phat import InkyPHAT, InkyPHAT_SSD1608 # noqa: F401
from .what import InkyWHAT # noqa: F401
from .mock import InkyMockPHAT, InkyMockWHAT # noqa: F401
from .inky_uc8159 import Inky as Inky7Colour # noqa: F401
from .inky_ssd1683 import Inky as InkyWHAT_SSD1683 # noqa: F401
from . import inky # noqa: F401
from .auto import auto # noqa: F401
from .inky import BLACK, RED, WHITE, YELLOW # noqa: F401
from .inky_ac073tc1a import Inky as Inky_Impressions_7 # noqa: F401
from .auto import auto # noqa: F401
from .inky_ssd1683 import Inky as InkyWHAT_SSD1683 # noqa: F401
from .inky_uc8159 import Inky as Inky7Colour # noqa: F401
from .mock import InkyMockPHAT, InkyMockWHAT # noqa: F401
from .phat import InkyPHAT, InkyPHAT_SSD1608 # noqa: F401
from .what import InkyWHAT # noqa: F401

__version__ = '1.5.0'

Expand Down
12 changes: 6 additions & 6 deletions inky/auto.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Automatic Inky setup from i2c EEPROM."""
from .phat import InkyPHAT, InkyPHAT_SSD1608 # noqa: F401
from .what import InkyWHAT # noqa: F401
from .inky_uc8159 import Inky as InkyUC8159 # noqa: F401
from .inky_ssd1683 import Inky as InkyWHAT_SSD1683 # noqa: F401
from .inky_ac073tc1a import Inky as InkyAC073TC1A # noqa: F401
from . import eeprom
import argparse

from . import eeprom
from .inky_ac073tc1a import Inky as InkyAC073TC1A # noqa: F401
from .inky_ssd1683 import Inky as InkyWHAT_SSD1683 # noqa: F401
from .inky_uc8159 import Inky as InkyUC8159 # noqa: F401
from .phat import InkyPHAT, InkyPHAT_SSD1608 # noqa: F401
from .what import InkyWHAT # noqa: F401

DISPLAY_TYPES = ["what", "phat", "phatssd1608", "impressions", "7colour", "whatssd1683", "impressions73"]
DISPLAY_COLORS = ["red", "black", "yellow"]
Expand Down
1 change: 0 additions & 1 deletion inky/eeprom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import datetime
import struct


EEP_ADDRESS = 0x50
EEP_WP = 12

Expand Down
2 changes: 1 addition & 1 deletion inky/inky.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Inky e-Ink Display Driver."""
import time
import struct
import time

from . import eeprom

Expand Down
1 change: 1 addition & 0 deletions inky/inky_ssd1608.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import time

from PIL import Image

from . import eeprom, ssd1608

try:
Expand Down
1 change: 1 addition & 0 deletions inky/inky_ssd1683.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import time

from PIL import Image

from . import eeprom, ssd1683

try:
Expand Down
2 changes: 1 addition & 1 deletion inky/inky_uc8159.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Inky e-Ink Display Driver."""
import time
import struct
import time
import warnings

try:
Expand Down
6 changes: 2 additions & 4 deletions inky/mock.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""PIL/Tkinter based simulator for InkyWHAT and InkyWHAT."""
import numpy


from . import inky
from . import inky_uc8159
from . import inky, inky_uc8159


class InkyMock(inky.Inky):
Expand All @@ -23,7 +21,7 @@ def __init__(self, colour, h_flip=False, v_flip=False):
raise ImportError('Simulation requires tkinter')

try:
from PIL import ImageTk, Image
from PIL import Image, ImageTk
except ImportError:
raise ImportError('Simulation requires PIL ImageTk and Image')

Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
import sys
from unittest import mock

import pytest

from tools import MockSMBus
Expand Down
9 changes: 3 additions & 6 deletions tests/test_auto.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Auto-detect tests for Inky."""
import pytest
import sys

import pytest

DISPLAY_VARIANT = [
None,
Expand Down Expand Up @@ -32,8 +32,7 @@
@pytest.mark.parametrize('inky_type', ['phat', 'what', 'phatssd1608', 'impressions', '7colour', 'whatssd1683'])
def test_auto_fallback(spidev, smbus2, PIL, inky_type, inky_colour, verbose):
"""Test auto init of 'phat', 'black'."""
from inky import InkyPHAT, InkyPHAT_SSD1608, InkyWHAT, Inky7Colour, InkyWHAT_SSD1683
from inky import auto
from inky import Inky7Colour, InkyPHAT, InkyPHAT_SSD1608, InkyWHAT, InkyWHAT_SSD1683, auto

if inky_type in ['impressions', '7colour']:
if inky_colour is not None:
Expand Down Expand Up @@ -64,9 +63,7 @@ def test_auto_fallback(spidev, smbus2, PIL, inky_type, inky_colour, verbose):
@pytest.mark.parametrize('inky_display', enumerate(DISPLAY_VARIANT))
def test_auto(spidev, smbus2_eeprom, PIL, inky_display):
"""Test auto init of 'phat', 'black'."""
from inky import InkyPHAT, InkyPHAT_SSD1608, InkyWHAT, Inky7Colour, InkyWHAT_SSD1683
from inky import auto
from inky import eeprom
from inky import Inky7Colour, InkyPHAT, InkyPHAT_SSD1608, InkyWHAT, InkyWHAT_SSD1683, auto, eeprom

display_id, display_name = inky_display

Expand Down
4 changes: 2 additions & 2 deletions tests/test_eeprom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

def test_eeprom_7color_5_7_inch(spidev, smbus2_eeprom, PIL):
"""Test EEPROM for 7color 5.7" Inky."""
from inky.inky_uc8159 import Inky
from inky.eeprom import EPDType
from inky.inky_uc8159 import Inky

eeprom_data = EPDType(600, 448, 0, 0, 14).encode()

Expand All @@ -17,8 +17,8 @@ def test_eeprom_7color_5_7_inch(spidev, smbus2_eeprom, PIL):

def test_eeprom_7color_4_inch(spidev, smbus2_eeprom, PIL):
"""Test EEPROM for 7color 4" Inky."""
from inky.inky_uc8159 import Inky
from inky.eeprom import EPDType
from inky.inky_uc8159 import Inky

eeprom_data = EPDType(640, 400, 0, 0, 16).encode()

Expand Down
1 change: 1 addition & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Initialization tests for Inky."""

from unittest import mock

import pytest


Expand Down

0 comments on commit 02d64d1

Please sign in to comment.