Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed Nov 5, 2024
1 parent ff9d019 commit be8ffba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions .cross_sync/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,15 @@ def visit_If(self, node):

def _is_async_check(self, node) -> bool:
"""
Check for CrossSync.is_async nodes
"""
return isinstance(node, ast.Attribute) and isinstance(node.value, ast.Name) and node.value.id == "CrossSync" and node.attr == "is_async"
Check for CrossSync.is_async or CrossSync.is_async == True checks
"""
if isinstance(node, ast.Attribute):
# for CrossSync.is_async
return isinstance(node.value, ast.Name) and node.value.id == "CrossSync" and node.attr == "is_async"
elif isinstance(node, ast.Compare):
# for CrossSync.is_async == True
return self._is_async_check(node.left) and (isinstance(node.ops[0], ast.Eq) or isinstance(node.ops[0], ast.Is)) and len(node.comparators) == 1 and node.comparators[0].value == True
return False


class CrossSyncFileProcessor(ast.NodeTransformer):
Expand Down
4 changes: 2 additions & 2 deletions tests/system/cross_sync/test_cases/cross_sync_files.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ tests:
@CrossSync.convert_class(sync_name="MyClass")
@some_other_decorator
class MyAsyncClass:
@CrossSync.convert
@CrossSync.convert(rm_aio=False)
async def my_method(self):
async with self.base.connection():
return await self.base.my_method()
Expand Down Expand Up @@ -269,7 +269,7 @@ tests:
transformers: [CrossSyncFileProcessor]
after: |
def sync_method(self, arg):
return await self.helper(arg)
return self.helper(arg)
- description: "Convert async method with rm_aio=True"
before: |
Expand Down

0 comments on commit be8ffba

Please sign in to comment.