Skip to content

Commit

Permalink
Merge pull request #879 from oddstr13/pr-flake8-3
Browse files Browse the repository at this point in the history
Enable flake8 pre-commit
  • Loading branch information
oddstr13 authored Jun 11, 2024
2 parents d731c80 + 415fa8c commit 6a072cc
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
10 changes: 6 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion jellyfin_kodi/entrypoint/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
2 changes: 1 addition & 1 deletion jellyfin_kodi/helper/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

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)
Expand Down
4 changes: 2 additions & 2 deletions jellyfin_kodi/helper/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def wrapper(self, item=None, *args, **kwargs):

dialog = xbmcgui.DialogProgressBG()

if item and type(item) == dict:
if item and isinstance(item, dict):

dialog.create(
translate("addon_name"),
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion jellyfin_kodi/objects/obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def map(self, item, mapping_name):
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)
)

Expand Down
10 changes: 7 additions & 3 deletions jellyfin_kodi/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def add_node(self, index, file, view, node, name):
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"]
Expand Down Expand Up @@ -847,7 +847,9 @@ def window_node(self, index, view, node=None, node_label=None):
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"):
Expand Down Expand Up @@ -896,7 +898,9 @@ def window_wnode(self, index, view, node=None, node_label=None):
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":
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 6a072cc

Please sign in to comment.