Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linter: Enable more ruff format/linter rules #2010

Merged
merged 21 commits into from
Jul 8, 2024
Merged

Conversation

glensc
Copy link
Collaborator

@glensc glensc commented Jul 8, 2024

@glensc glensc self-assigned this Jul 8, 2024
glensc added 21 commits July 8, 2024 16:18
37 |         for v in items:
38 |             yield i, v
39 |             i += 1
   |             ^^^^^^ SIM113
40 |
41 |     else:
…`pass`

22 |   # Delete environment to ensure consistent tests
23 |   for key in config.env_keys:
24 |       try:
   |  _____^
25 | |         del environ[key]
26 | |     except KeyError:
27 | |         pass
   | |____________^ SIM105
   |
   = help: Replace with `contextlib.suppress(KeyError)`
…`pass`

12 |           """
13 |           for key in keys or []:
14 |               try:
   |  _____________^
15 | |                 del self.__dict__[key]
16 | |             except KeyError:
17 | |                 pass
   | |____________________^ SIM105
18 |
19 |       @cached_property
   |
   = help: Replace with `contextlib.suppress(KeyError)`
…cept`-`pass`

49 |       root = ElementTree.fromstring(data)
50 |       try:
   |  _____^
51 | |         # requires python 3.9
52 | |         # https://stackoverflow.com/a/39482716/2314626
53 | |         ElementTree.indent(root)
54 | |     except AttributeError:
55 | |         pass
   | |____________^ SIM105
56 |
57 |       return ElementTree.tostring(root, encoding="utf8").decode("utf8")
   |
   = help: Replace with `contextlib.suppress(AttributeError)`
83 |               return False
84 |           id_from_trakt = getattr(episode, guid.provider, None)
85 |           if str(id_from_trakt) != guid.id:
   |  _________^
86 | |             return True
87 | |         return False
   | |____________________^ SIM103
88 |
89 |       def from_number(self, season: int, number: int):
   |
   = help: Replace with `return str(id_from_trakt) != guid.id`
134 |             show_id = ep.show_id
135 |             ep.show = plex_shows[show_id]
136 |             show = show_cache[show_id] if show_id in show_cache else None
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SIM401
137 |             m = self.mf.resolve_any(ep, show)
138 |             if not m:
    |
    = help: Replace with `show_cache.get(show_id, None)`
122 |       def is_collected(self, trakt_id, season, episode):
123 |           if trakt_id not in self.shows.keys():
    |  _________^
124 | |             return False
125 | |         elif season not in self.shows[trakt_id].seasons.keys():
126 | |             return False
    | |________________________^ SIM114
127 |           return episode in self.shows[trakt_id].seasons[season].episodes.keys()
    |
    = help: Combine `if` branches
35 | def make(cls=None, **kwargs) -> Union[TVShow]:
   |                                 ^^^^^^^^^^^^^ UP007
36 |     cls = cls if cls is not None else "object"
37 |     # https://stackoverflow.com/a/2827726/2314626
   |
   = help: Convert to `X | Y`
30 |   def limit_iterator(items, limit: int):
31 |       if not limit or limit <= 0:
32 |           for i, v in enumerate(items):
   |  _________^
33 | |             yield i, v
   | |______________________^ UP028
34 |
35 |       else:
   |
   = help: Replace with `yield from`
@glensc glensc merged commit 2431e17 into Taxel:main Jul 8, 2024
3 checks passed
@glensc glensc deleted the ruff-configure branch July 8, 2024 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant