Skip to content

Commit

Permalink
some dunders
Browse files Browse the repository at this point in the history
  • Loading branch information
pomponchik committed Jun 17, 2024
1 parent 2f8a5c7 commit 61e0d8b
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions f/proxy_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import inspect
from string import Formatter
from types import CodeType, FrameType
from typing import Iterable, Optional, Union, Sized, Dict, Callable, Type, Any
from typing import Set, Iterable, Optional, Union, Sized, Dict, Callable, Type, Any
try:
from typing import Protocol
except ImportError:
Expand Down Expand Up @@ -43,6 +43,12 @@ def __call__(self, string: Union[LazyString, str], lazy: bool = True, safe: bool
return result
return result.data

def __str__(self) -> str:
return 'f'

def __repr__(self) -> str:
return 'f'

def sum_of_nonlocals(self, first_frame: Optional[FrameType], base_qualname: Optional[str], closures: bool, safe: bool) -> Dict[str, Any]:
if not closures or first_frame is None or base_qualname is None:
return {}
Expand Down Expand Up @@ -152,8 +158,13 @@ def startswith(iterable: SizedAndIterable, second_iterable: SizedAndIterable) ->

return True

def __str__(self) -> str:
return 'f'
def get_all_mentioned_names(self, string: str) -> Set[str]:
result = set()

def __repr__(self) -> str:
return 'f'
class Visiter(ast.NodeVisitor):
def visit_Name(_self, node: ast.AST) -> Optional[ast.AST]:
result.add(node.id)

Visiter().visit(ast.parse(string))

return result

0 comments on commit 61e0d8b

Please sign in to comment.