Skip to content

Commit

Permalink
Add annotiations to some globals ...
Browse files Browse the repository at this point in the history
and add run pytest setting MATHICS_CHARACTER_ENCODING
  • Loading branch information
rocky committed Nov 21, 2022
1 parent 530e147 commit da8580c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ clean: clean-cython clean-cache

#: Run py.test tests. Use environment variable "o" for pytest options
pytest:
$(PYTHON) -m pytest $(PYTEST_WORKERS) test $o
MATHICS_CHARACTER_ENCODING="ASCII" $(PYTHON) -m pytest $(PYTEST_WORKERS) test $o


#: Run a more extensive pattern-matching test
Expand Down
17 changes: 12 additions & 5 deletions mathics/builtin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import os.path as osp
import pkgutil
import re
from typing import List, Optional
from typing import Dict, List, Optional, Type

from mathics.builtin.base import (
Builtin,
Expand All @@ -31,11 +31,18 @@
for f in glob.glob(osp.join(osp.dirname(__file__), "[a-z]*.py"))
]

system_builtins_dict = {}
builtins_by_module = {}
# system_builtins_dict maps a full builtin name, e.g. "System`EulerPhi" to a Builtin class
system_builtins_dict: Dict[str, Type[Builtin]] = {}

# builtins_by_module maps a full module name, e.g. "mathics.builtin.evaluation" to a
# list of Builtin classes.
builtins_by_module: Dict[str, List[Type[Builtin]]] = {}

def add_builtins(new_builtins):

def add_builtins(new_builtins: list):
"""
Updates system_builtins_dict to insert new_builtins.
"""
for var_name, builtin in new_builtins:
name = builtin.get_name()
if hasattr(builtin, "python_equivalent"):
Expand Down Expand Up @@ -233,7 +240,7 @@ def sanity_check(cls, module):
_builtins_list.append((instance.get_name(), instance))
builtins_by_module[module.__name__].append(instance)

mathics_to_sympy = {} # here we have: name -> sympy object
mathics_to_sympy: Dict[str, Type[Builtin]] = {} # here we have: name -> sympy object
sympy_to_mathics = {}

builtins_precedence = {}
Expand Down

0 comments on commit da8580c

Please sign in to comment.