Skip to content

Remove a bunch of lints I don't like#147

Merged
msullivan merged 1 commit into
mainfrom
linter-trim
May 22, 2026
Merged

Remove a bunch of lints I don't like#147
msullivan merged 1 commit into
mainfrom
linter-trim

Conversation

@msullivan
Copy link
Copy Markdown
Contributor

Here are some of them:

src/ai/types/messages.py:44:5: SIM102 Use a single `if` statement instead of nested `if` statements
   |
42 |       if _is_file_part_dict(value):
43 |           return FilePart.model_validate(value)
44 |       if isinstance(value, list):
   |  _____^
45 | |         if any(_is_file_part_dict(item) for item in value):
   | |___________________________________________________________^ SIM102
46 |               return [
47 |                   FilePart.model_validate(item)
   |
   = help: Combine `if` statements using `and`

src/ai/types/messages.py:87:13: PLC2801 Unnecessary dunder call to `__setattr__`. Mutate attribute directly or use setattr built-in function.
   |
85 |         if rehydrated is not self.result:
86 |             # Bypass frozen protection for post-init fixup.
87 |             object.__setattr__(self, "result", rehydrated)
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC2801
88 |         return self
   |
   = help: Mutate attribute directly or use setattr built-in function

tests/providers/ai_gateway/test_protocol.py:452:46: PLC1901 `result["value"][0]["data"] != ""` can be simplified to `result["value"][0]["data"]` as an empty string is falsey
    |
450 |         assert result["value"][0]["type"] == "image-data"
451 |         # Should be base64-encoded
452 |         assert result["value"][0]["data"] != ""
    |                                              ^^ PLC1901
    |

I actually might agree with the first one but I don't really want a
linter making that sort of suggestion.

Here are some of them:
```
src/ai/types/messages.py:44:5: SIM102 Use a single `if` statement instead of nested `if` statements
   |
42 |       if _is_file_part_dict(value):
43 |           return FilePart.model_validate(value)
44 |       if isinstance(value, list):
   |  _____^
45 | |         if any(_is_file_part_dict(item) for item in value):
   | |___________________________________________________________^ SIM102
46 |               return [
47 |                   FilePart.model_validate(item)
   |
   = help: Combine `if` statements using `and`

src/ai/types/messages.py:87:13: PLC2801 Unnecessary dunder call to `__setattr__`. Mutate attribute directly or use setattr built-in function.
   |
85 |         if rehydrated is not self.result:
86 |             # Bypass frozen protection for post-init fixup.
87 |             object.__setattr__(self, "result", rehydrated)
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PLC2801
88 |         return self
   |
   = help: Mutate attribute directly or use setattr built-in function

tests/providers/ai_gateway/test_protocol.py:452:46: PLC1901 `result["value"][0]["data"] != ""` can be simplified to `result["value"][0]["data"]` as an empty string is falsey
    |
450 |         assert result["value"][0]["type"] == "image-data"
451 |         # Should be base64-encoded
452 |         assert result["value"][0]["data"] != ""
    |                                              ^^ PLC1901
    |
```

I actually might agree with the first one but I don't really want a
linter making that sort of suggestion.
@msullivan msullivan requested review from anbuzin and elprans May 21, 2026 00:38
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ai-python Ready Ready Preview, Comment May 21, 2026 12:40am

@msullivan msullivan merged commit 896ee5a into main May 22, 2026
7 checks passed
@msullivan msullivan deleted the linter-trim branch May 22, 2026 16:48
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.

3 participants