Skip to content

Commit aff9c84

Browse files
committed
Make Rule's unasync functions public for overwriting
1 parent e56590d commit aff9c84

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/unasync/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,27 +89,30 @@ def _unasync_tokens(self, tokens):
8989
skip_next = True
9090
else:
9191
if token.name == "NAME":
92-
token = token._replace(src=self._unasync_name(token.src))
92+
token = token._replace(src=self.unasync_name(token.src))
9393
elif token.name == "STRING":
94-
left_quote, name, right_quote = (
94+
left_quote, string, right_quote = (
9595
token.src[0],
9696
token.src[1:-1],
9797
token.src[-1],
9898
)
9999
token = token._replace(
100-
src=left_quote + self._unasync_name(name) + right_quote
100+
src=left_quote + self.unasync_string(string) + right_quote
101101
)
102102

103103
yield token
104104

105-
def _unasync_name(self, name):
105+
def unasync_name(self, name):
106106
if name in self.token_replacements:
107107
return self.token_replacements[name]
108108
# Convert classes prefixed with 'Async' into 'Sync'
109109
elif len(name) > 5 and name.startswith("Async") and name[5].isupper():
110110
return "Sync" + name[5:]
111111
return name
112112

113+
def unasync_string(self, string):
114+
return self.unasync_name(string)
115+
113116

114117
def unasync_files(fpath_list, rules):
115118
for f in fpath_list:

0 commit comments

Comments
 (0)