Skip to content

Commit 217782e

Browse files
authored
Remove PyFunctional dependency (#589)
* Remove PyFunctional dependency * Docstring
1 parent b61024e commit 217782e

File tree

10 files changed

+64
-104
lines changed

10 files changed

+64
-104
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
* Fixed a bug where `def` forms did not permit recursive references to the `def`'ed Vars (#578)
2222
* Fixed a bug where `concat` could cause a `RecursionEror` if used on a `LazySeq` instance which itself calls `concat` (#588)
2323

24+
### Removed
25+
* Removed `pyfunctional` dependency in favor of Python standard library functions (#589)
26+
2427
## [v0.1.dev14] - 2020-06-18
2528
### Added
2629
* Added support for `future`s (#441)

Pipfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,26 @@ name = "pypi"
66
[dev-packages]
77
black = "*"
88
docutils = "==0.15"
9+
isort = "*"
910
pygments = "*"
1011
pytest-pycharm = "*"
1112
sphinx = "*"
1213
sphinx-rtd-theme = "*"
1314
tox = "*"
1415
tox-pyenv = "*"
1516
twine = "*"
16-
isort = "*"
1717

1818
[packages]
1919
astor = "*"
2020
atomos = "*"
2121
attrs = "*"
2222
basilisp = {editable = true,path = "."}
2323
click = "*"
24+
immutables = "*"
2425
prompt-toolkit = "~=3.0.0"
25-
pyfunctional = "*"
2626
pyrsistent = "*"
2727
python-dateutil = "*"
2828
pytest = "*"
29-
immutables = "*"
3029

3130
[requires]
3231
python_version = "3.6"

Pipfile.lock

Lines changed: 37 additions & 66 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mypy.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ ignore_missing_imports = True
88
[mypy-astor.*]
99
ignore_missing_imports = True
1010

11-
[mypy-functional.*]
12-
ignore_missing_imports = True
13-
1411
[mypy-prompt_toolkit.*]
1512
ignore_missing_imports = True
1613

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"click",
2828
"immutables",
2929
"prompt-toolkit>=3.0.0",
30-
"pyfunctional",
3130
"pyrsistent",
3231
"pytest",
3332
"python-dateutil",

src/basilisp/lang/compiler/generator.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3134,15 +3134,16 @@ def _str_to_py_ast(_: GeneratorContext, form: str) -> ast.AST:
31343134
def _const_sym_to_py_ast(ctx: GeneratorContext, form: sym.Symbol) -> GeneratedPyAST:
31353135
meta = _const_meta_kwargs_ast(ctx, form)
31363136

3137-
sym_kwargs = (
3137+
sym_kwarg = (
31383138
Maybe(form.ns)
3139-
.stream()
3140-
.map(lambda v: ast.keyword(arg="ns", value=ast.Constant(v)))
3141-
.to_list()
3139+
.map(lambda v: [ast.keyword(arg="ns", value=ast.Constant(v))])
3140+
.or_else(list)
31423141
)
3143-
sym_kwargs.extend(Maybe(meta).map(lambda p: [p.node]).or_else_get([]))
3142+
meta_kwarg = Maybe(meta).map(lambda p: [p.node]).or_else(list)
31443143
base_sym = ast.Call(
3145-
func=_NEW_SYM_FN_NAME, args=[ast.Constant(form.name)], keywords=sym_kwargs
3144+
func=_NEW_SYM_FN_NAME,
3145+
args=[ast.Constant(form.name)],
3146+
keywords=list(chain(sym_kwarg, meta_kwarg)),
31463147
)
31473148

31483149
return GeneratedPyAST(
@@ -3155,9 +3156,8 @@ def _const_sym_to_py_ast(ctx: GeneratorContext, form: sym.Symbol) -> GeneratedPy
31553156
def _kw_to_py_ast(_: GeneratorContext, form: kw.Keyword) -> ast.AST:
31563157
kwarg = (
31573158
Maybe(form.ns)
3158-
.stream()
3159-
.map(lambda ns: ast.keyword(arg="ns", value=ast.Constant(form.ns)))
3160-
.to_list()
3159+
.map(lambda ns: [ast.keyword(arg="ns", value=ast.Constant(form.ns))])
3160+
.or_else(list)
31613161
)
31623162
return ast.Call(
31633163
func=_NEW_KW_FN_NAME, args=[ast.Constant(form.name)], keywords=kwarg

src/basilisp/lang/obj.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from functools import singledispatch
99
from typing import Any, Callable, Iterable, Pattern, Tuple, Union
1010

11-
from functional import seq
11+
from basilisp.util import take
1212

1313
PrintCountSetting = Union[bool, int, None]
1414

@@ -92,7 +92,7 @@ def entry_reprs():
9292
print_dup = kwargs["print_dup"]
9393
print_length = kwargs["print_length"]
9494
if not print_dup and isinstance(print_length, int):
95-
items = seq(entry_reprs()).take(print_length + 1).to_list()
95+
items = list(take(entry_reprs(), print_length + 1))
9696
if len(items) > print_length:
9797
items.pop()
9898
trailer.append(SURPASSED_PRINT_LENGTH)
@@ -124,12 +124,12 @@ def seq_lrepr(
124124
print_dup = kwargs["print_dup"]
125125
print_length = kwargs["print_length"]
126126
if not print_dup and isinstance(print_length, int):
127-
items = seq(iterable).take(print_length + 1).to_list()
127+
items = list(take(iterable, print_length + 1))
128128
if len(items) > print_length:
129129
items.pop()
130130
trailer.append(SURPASSED_PRINT_LENGTH)
131131
else:
132-
items = iterable
132+
items = iterable # type: ignore
133133

134134
items = list(map(lambda o: lrepr(o, **kwargs), items))
135135
seq_lrepr = PRINT_SEPARATOR.join(items + trailer)

src/basilisp/lang/reader.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
)
3030

3131
import attr
32-
from functional import seq
3332

3433
import basilisp.lang.keyword as keyword
3534
import basilisp.lang.list as llist
@@ -1111,8 +1110,8 @@ def _process_syntax_quoted_form(
11111110
elif isinstance(form, lset.Set):
11121111
return llist.l(_APPLY, _HASH_SET, lconcat(_expand_syntax_quote(ctx, form)))
11131112
elif isinstance(form, lmap.Map):
1114-
flat_kvs = seq(form.items()).flatten().to_list()
1115-
return llist.l(_APPLY, _HASH_MAP, lconcat(_expand_syntax_quote(ctx, flat_kvs)))
1113+
flat_kvs = list(chain.from_iterable(form.items()))
1114+
return llist.l(_APPLY, _HASH_MAP, lconcat(_expand_syntax_quote(ctx, flat_kvs))) # type: ignore
11161115
elif isinstance(form, symbol.Symbol):
11171116
if form.ns is None and form.name.endswith("#"):
11181117
try:

0 commit comments

Comments
 (0)