Merge pull request #879 from oddstr13/pr-flake8-3

Enable flake8 pre-commit
This commit is contained in:
Odd Stråbø 2024-06-11 04:38:30 +02:00 committed by GitHub
commit 6a072cc71b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 20 additions and 13 deletions

View file

@ -20,10 +20,12 @@ repos:
hooks:
- id: black
# - repo: https://github.com/pycqa/flake8
# rev: 7.0.0
# hooks:
# - id: flake8
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
- flake8-import-order
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.9.0

View file

@ -619,7 +619,7 @@ def browse(media, view_id=None, folder=None, server_id=None, api_client=None):
actions = Actions(server_id, api_client)
list_li = []
listing = listing if type(listing) == list else listing.get("Items", [])
listing = listing if isinstance(listing, list) else listing.get("Items", [])
for item in listing:

View file

@ -16,7 +16,7 @@ LOG = LazyLogger(__name__)
def translate(string):
"""Get add-on string. Returns in unicode."""
if type(string) != int:
if not isinstance(string, int):
string = STRINGS[string]
result = xbmcaddon.Addon("plugin.video.jellyfin").getLocalizedString(string)

View file

@ -26,7 +26,7 @@ def progress(message=None):
dialog = xbmcgui.DialogProgressBG()
if item and type(item) == dict:
if item and isinstance(item, dict):
dialog.create(
translate("addon_name"),
@ -74,7 +74,7 @@ def jellyfin_item(func):
def wrapper(self, item, *args, **kwargs):
e_item = self.jellyfin_db.get_item_by_id(
item["Id"] if type(item) == dict else item
item["Id"] if isinstance(item, dict) else item
)
return func(self, item, e_item=e_item, *args, **kwargs)

View file

@ -104,7 +104,7 @@ class Objects(object):
if obj_key:
obj = (
[d[obj_key] for d in obj if d.get(obj_key)]
if type(obj) == list
if isinstance(obj, list)
else obj.get(obj_key)
)

View file

@ -444,7 +444,7 @@ class Views(object):
etree.SubElement(xml, "content")
label = xml.find("label")
label.text = str(name) if type(name) == int else name
label.text = str(name) if isinstance(name, int) else name
content = xml.find("content")
content.text = view["Media"]
@ -847,7 +847,9 @@ class Views(object):
else:
window_path = "ActivateWindow(Videos,%s,return)" % path
node_label = translate(node_label) if type(node_label) == int else node_label
node_label = (
translate(node_label) if isinstance(node_label, int) else node_label
)
node_label = node_label or view["Name"]
if node in ("all", "music"):
@ -896,7 +898,9 @@ class Views(object):
else:
window_path = "ActivateWindow(Videos,%s,return)" % path
node_label = translate(node_label) if type(node_label) == int else node_label
node_label = (
translate(node_label) if isinstance(node_label, int) else node_label
)
node_label = node_label or view["Name"]
if node == "all":

View file

@ -1,9 +1,10 @@
[flake8]
max-line-length = 9999
import-order-style = pep8
exclude = .git,.vscode,libraries,build.py,.github
exclude = .git,.vscode
extend-ignore =
I202
E203
per-file-ignores =
*/__init__.py: F401
tests/test_imports.py: F401