Skip to content

Commit

Permalink
chore: ruff cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Dec 15, 2023
1 parent 3b685c8 commit e1b51c5
Show file tree
Hide file tree
Showing 184 changed files with 296 additions and 483 deletions.
1 change: 0 additions & 1 deletion prettyqt/animations/textanimation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import logging

from typing import Literal

from prettyqt import core
Expand Down
1 change: 0 additions & 1 deletion prettyqt/charts/xyseries.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import prettyqt

from prettyqt import charts, core, gui
from prettyqt.utils import datatypes

Expand Down
3 changes: 1 addition & 2 deletions prettyqt/core/_datetime.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import annotations

import datetime

from typing_extensions import Self
from typing import Self

from prettyqt import constants, core

Expand Down
4 changes: 1 addition & 3 deletions prettyqt/core/_locale.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations

from typing import Literal

from typing_extensions import Self
from typing import Literal, Self

from prettyqt import constants
from prettyqt.qt import QtCore
Expand Down
2 changes: 1 addition & 1 deletion prettyqt/core/_time.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing_extensions import Self
from typing import Self

from prettyqt import core

Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/abstractanimation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import functools

from typing import Literal

from prettyqt import core
Expand Down
12 changes: 5 additions & 7 deletions prettyqt/core/abstractitemmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from collections.abc import Iterator, Sequence
import contextlib
import logging

from typing import Any, Literal, overload

from prettyqt import constants, core
Expand Down Expand Up @@ -56,14 +55,12 @@ def __add__(self, other: core.QAbstractItemModel) -> core.ConcatenateTablesProxy
return proxy

@overload
def __getitem__(self, index: tuple[int, int] | int) -> core.ModelIndex:
...
def __getitem__(self, index: tuple[int, int] | int) -> core.ModelIndex: ...

@overload
def __getitem__(
self, index: tuple[slice, int] | tuple[int, slice] | tuple[slice, slice]
) -> listdelegators.ListDelegator[core.ModelIndex]:
...
) -> listdelegators.ListDelegator[core.ModelIndex]: ...

def __getitem__(
self, index: tuple[int | slice, int | slice]
Expand Down Expand Up @@ -410,8 +407,9 @@ def to_checkstate(value: bool):
def get_header_index_for_value(
self,
label,
orientation: constants.Orientation
| constants.OrientationStr = constants.HORIZONTAL,
orientation: (
constants.Orientation | constants.OrientationStr
) = constants.HORIZONTAL,
*,
role: constants.ItemDataRole = constants.DISPLAY_ROLE,
) -> int | None:
Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/abstractproxymodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from collections.abc import Callable, Generator, Sequence
import logging

from typing import Any

from prettyqt import core, qt
Expand Down
2 changes: 1 addition & 1 deletion prettyqt/core/date.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing_extensions import Self
from typing import Self

from prettyqt import constants
from prettyqt.qt import QtCore
Expand Down
5 changes: 1 addition & 4 deletions prettyqt/core/dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
from collections.abc import Iterable
import os
import pathlib

from typing import Literal

from typing_extensions import Self
from typing import Literal, Self

from prettyqt import core
from prettyqt.utils import bidict, datatypes, get_repr
Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/diriterator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import pathlib

from typing import Literal

from prettyqt import core
Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/filedevice.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import datetime

from typing import Literal

from prettyqt import core
Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/fileinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import os
import pathlib

from typing import Any

from prettyqt import core
Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/fileselector.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import os

from typing import TYPE_CHECKING

from prettyqt import core
Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/iodevice.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import contextlib

from typing import Literal

from prettyqt import core
Expand Down
4 changes: 1 addition & 3 deletions prettyqt/core/jsondocument.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations

from typing import Literal

from typing_extensions import Self
from typing import Literal, Self

from prettyqt import core
from prettyqt.utils import bidict, get_repr
Expand Down
23 changes: 10 additions & 13 deletions prettyqt/core/keycombination.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import functools

from operator import or_

from prettyqt import constants
Expand All @@ -12,18 +11,16 @@
Mod = constants.KeyboardModifier
Key = constants.Key

MODIFIERS = bidict(
{
"None": Mod.NoModifier,
"Shift": Mod.ShiftModifier,
"Ctrl": Mod.ControlModifier,
"Alt": Mod.AltModifier,
"Meta": Mod.MetaModifier,
"Ctrl+Shift": Mod.ControlModifier | Mod.ShiftModifier,
"Ctrl+Alt": Mod.ControlModifier | Mod.AltModifier,
"Alt+Shift": Mod.AltModifier | Mod.ShiftModifier,
}
)
MODIFIERS = bidict({
"None": Mod.NoModifier,
"Shift": Mod.ShiftModifier,
"Ctrl": Mod.ControlModifier,
"Alt": Mod.AltModifier,
"Meta": Mod.MetaModifier,
"Ctrl+Shift": Mod.ControlModifier | Mod.ShiftModifier,
"Ctrl+Alt": Mod.ControlModifier | Mod.AltModifier,
"Alt+Shift": Mod.AltModifier | Mod.ShiftModifier,
})

MODIFIER_KEYS = frozenset({Key.Key_Shift, Key.Key_Control, Key.Key_Meta, Key.Key_Alt})
ARROW_KEYS = frozenset({Key.Key_Up, Key.Key_Down, Key.Key_Left, Key.Key_Right})
Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/libraryinfo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import pathlib

from typing import Literal

from prettyqt import core
Expand Down
5 changes: 1 addition & 4 deletions prettyqt/core/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

from collections.abc import Iterator
import math

from typing import Literal

from typing_extensions import Self
from typing import Literal, Self

from prettyqt import core
from prettyqt.utils import datatypes, get_repr
Expand Down
4 changes: 1 addition & 3 deletions prettyqt/core/linef.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from __future__ import annotations

from collections.abc import Iterator
from typing import Literal

from typing_extensions import Self
from typing import Literal, Self

from prettyqt import core
from prettyqt.utils import datatypes, get_repr
Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/lockfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import contextlib
import os

from typing import Literal

from prettyqt.qt import QtCore
Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/metaobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from collections.abc import Callable
import logging

from typing import Any, TypeVar

from prettyqt import constants, core
Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/metatype.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import enum

from typing import Literal

from prettyqt.qt import QtCore
Expand Down
4 changes: 1 addition & 3 deletions prettyqt/core/mimedata.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from __future__ import annotations

from collections.abc import Iterable, Iterator
from typing import Any

from typing_extensions import Self
from typing import Any, Self

from prettyqt import core
from prettyqt.utils import datatypes, helpers
Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/mimedatabase.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import os

from typing import Literal

from prettyqt import core
Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import logging
import re
import types

from typing import TYPE_CHECKING, Any, TypeVar, get_args

from prettyqt import constants, core
Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/process.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import contextlib

from typing import Literal

from prettyqt import core
Expand Down
3 changes: 1 addition & 2 deletions prettyqt/core/processenvironment.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import annotations

from collections.abc import Iterator, MutableMapping

from typing_extensions import Self
from typing import Self

from prettyqt.qt import QtCore
from prettyqt.utils import datatypes
Expand Down
2 changes: 1 addition & 1 deletion prettyqt/core/rect.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing_extensions import Self
from typing import Self

from prettyqt.qt import QtCore
from prettyqt.utils import datatypes, get_repr
Expand Down
15 changes: 6 additions & 9 deletions prettyqt/core/regularexpression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from collections.abc import Callable, Iterator
import re

from typing import Literal

import bidict as bd
Expand All @@ -11,14 +10,12 @@
from prettyqt.utils import bidict, get_repr


RE_MAP = bd.bidict(
{
re.IGNORECASE: core.QRegularExpression.PatternOption.CaseInsensitiveOption,
re.MULTILINE: core.QRegularExpression.PatternOption.MultilineOption,
re.DOTALL: core.QRegularExpression.PatternOption.DotMatchesEverythingOption,
re.VERBOSE: core.QRegularExpression.PatternOption.ExtendedPatternSyntaxOption,
}
)
RE_MAP = bd.bidict({
re.IGNORECASE: core.QRegularExpression.PatternOption.CaseInsensitiveOption,
re.MULTILINE: core.QRegularExpression.PatternOption.MultilineOption,
re.DOTALL: core.QRegularExpression.PatternOption.DotMatchesEverythingOption,
re.VERBOSE: core.QRegularExpression.PatternOption.ExtendedPatternSyntaxOption,
})

mod = core.QRegularExpression

Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from collections.abc import Iterator
import os
import pathlib

from typing import Literal

from prettyqt import core
Expand Down
5 changes: 1 addition & 4 deletions prettyqt/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import logging
import os
import sys

from typing import Any, Literal

from typing_extensions import Self
from typing import Any, Literal, Self

from prettyqt import core
from prettyqt.utils import bidict, datatypes
Expand Down
2 changes: 1 addition & 1 deletion prettyqt/core/size.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing_extensions import Self
from typing import Self

from prettyqt.qt import QtCore
from prettyqt.utils import datatypes, get_repr
Expand Down
2 changes: 1 addition & 1 deletion prettyqt/core/sizef.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing_extensions import Self
from typing import Self

from prettyqt.qt import QtCore
from prettyqt.utils import datatypes, get_repr
Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/slot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import asyncio

from collections.abc import Callable, Iterable
import functools
import inspect
Expand Down
1 change: 0 additions & 1 deletion prettyqt/core/sortfilterproxymodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from collections.abc import Iterable
import enum
import re

from typing import Literal

from prettyqt import constants, core
Expand Down

0 comments on commit e1b51c5

Please sign in to comment.