Skip to content

Commit

Permalink
Remove excess quotes on the 3.10 type generator
Browse files Browse the repository at this point in the history
Remove the excess quotes on the 3.10 type generator for better type usage.
  • Loading branch information
imcdo authored Oct 15, 2024
1 parent 6a3bbe3 commit 120105b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/betterproto/plugin/typing_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,28 +146,28 @@ def _fmt(type: str) -> str: # for now this is necessary till 3.14
return type

def optional(self, type: str) -> str:
return f'"{self._fmt(type)} | None"'
return f'{self._fmt(type)} | None'

def list(self, type: str) -> str:
return f'"list[{self._fmt(type)}]"'
return f'list[{self._fmt(type)}]'

def dict(self, key: str, value: str) -> str:
return f'"dict[{key}, {self._fmt(value)}]"'
return f'dict[{key}, {self._fmt(value)}]'

def union(self, *types: str) -> str:
return f'"{" | ".join(map(self._fmt, types))}"'
return f'{" | ".join(map(self._fmt, types))}'

def iterable(self, type: str) -> str:
self._imports["collections.abc"].add("Iterable")
return f'"Iterable[{type}]"'
return f'Iterable[{type}]'

def async_iterable(self, type: str) -> str:
self._imports["collections.abc"].add("AsyncIterable")
return f'"AsyncIterable[{type}]"'
return f'AsyncIterable[{type}]'

def async_iterator(self, type: str) -> str:
self._imports["collections.abc"].add("AsyncIterator")
return f'"AsyncIterator[{type}]"'
return f'AsyncIterator[{type}]'

def imports(self) -> Dict[str, Optional[Set[str]]]:
return {k: v if v else None for k, v in self._imports.items()}

0 comments on commit 120105b

Please sign in to comment.