backends/xcode: simplify an obviously too-complicated function

This function has a pretty unique name, and a simple grep shows that it
is only ever called as:
```
add_comment(PbxComment('...........'))
```

It doesn't need to include logic such as handling str. Moreover it looks
like that handling was broken anyway... it handled the case where
comment is type str, by constructing a new PbxComment(str) instead of
PbxComment(comment), a condition that cannot ever be valid (and crashed
due to other assertions).

Fixes:

mesonbuild/backend/xcodebackend.py:148:42: error: Argument 1 to "PbxComment" has incompatible type "type[str]"; expected "str"  [arg-type]
pull/11864/head
Eli Schwartz 1 year ago
parent 50921263bd
commit f38c653a75
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 9
      mesonbuild/backend/xcodebackend.py

@ -138,12 +138,9 @@ class PbxDict:
def has_item(self, key):
return key in self.keys
def add_comment(self, comment: T.Union[str, PbxComment]) -> None:
if isinstance(comment, str):
self.items.append(PbxComment(str))
else:
assert isinstance(comment, PbxComment)
self.items.append(comment)
def add_comment(self, comment: PbxComment) -> None:
assert isinstance(comment, PbxComment)
self.items.append(comment)
def write(self, ofile: T.TextIO, indent_level: int) -> None:
ofile.write('{\n')

Loading…
Cancel
Save