Skip to content

Commit e7ad240

Browse files
committed
Merge branch 'main' into format-comments
2 parents 7f51d48 + 625fe36 commit e7ad240

9 files changed

Lines changed: 57 additions & 72 deletions

File tree

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ codecov.json
4242

4343
# Some paths we don't want to include. We could ignore these further down the
4444
# tree, but prettier relies on this file rather than resolving all the way down.
45-
**/.venv
46-
**/.nox
47-
**/vendor
45+
.venv
46+
.nox
47+
vendor
4848
.mypy_cache/
49+
.hypothesis/

Taskfile.yml

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ includes:
2727
web:
2828
taskfile: ./web
2929
dir: ./web
30+
python:
31+
taskfile: ./prqlc/bindings/prqlc-python
32+
dir: ./prqlc/bindings/prqlc-python
3033

3134
vars:
3235
# Keep in sync with .vscode/extensions.json
@@ -112,13 +115,7 @@ tasks:
112115

113116
install-cargo-tools-binstall:
114117
cmds:
115-
# Currently pinning 1.1.2 because of https://github.com/cargo-bins/cargo-binstall/issues/1292, and using `+stable` because it's not supported by 1.68.2.
116-
- cmd:
117-
# curl -L --proto '=https' --tlsv1.2 -sSf
118-
# https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh
119-
# | bash ||
120-
rustup toolchain add stable && cargo +stable install --locked
121-
cargo-binstall --version=1.1.2
118+
- cmd: cargo install --locked cargo-binstall
122119
platforms: [linux, darwin]
123120
- "cargo binstall -y --locked {{.cargo_crates}}"
124121

@@ -243,6 +240,7 @@ tasks:
243240
- cargo doc
244241
- task: web:build
245242
- task: build-each-crate
243+
- task: python:build
246244

247245
build-each-crate:
248246
summary: |
@@ -284,14 +282,15 @@ tasks:
284282
285283
cmds:
286284
# TODO:
287-
# - Add `prqlc-python` tests.
288285
# - We could add `prqlc-c` here.
289286
# - We deliberately don't test some other bindings, such as `prql-php`,
290-
# given they require more dependencies and aren't yet supported.
287+
# given they require more dependencies and aren't yet Supported. They
288+
# run in CI.
291289
- task: test-lint
292290
- task: test-rust
293291
- task: test-js
294292
- cargo insta test --accept --target=wasm32-unknown-unknown
293+
- task: python:test
295294
- task: build-all
296295

297296
test-rust:
@@ -383,26 +382,12 @@ tasks:
383382
dir: prqlc/bindings/php
384383
cmds:
385384
- vendor/bin/phpunit tests
386-
# The next three tasks are not used for either:
385+
# The next two tasks are not used for either:
387386
# - the Dockerfile (installing brew takes forever)
388387
# so the Dockerfile simply installs hugo & nodejs directly
389388
# - the "desktop setup" - it uses other tasks in the Taskfile.yml
390389
# They remain in the Taskfile.yml as a hint if they should ever be needed
391390

392-
# install-brew:
393-
# # Initially added for building Docker container
394-
# status:
395-
# - which brew
396-
# cmds:
397-
# # https://stackoverflow.com/questions/58292862/how-to-install-homebrew-on-ubuntu-inside-docker-container
398-
# - useradd -m -s /bin/zsh linuxbrew
399-
# - usermod -aG sudo linuxbrew
400-
# - mkdir -p /home/linuxbrew/.linuxbrew
401-
# - chown -R linuxbrew /home/linuxbrew/.linuxbrew
402-
# - export HOMEBREW_INSTALL_FROM_API=1
403-
# - /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
404-
# - chown -R $CONTAINER_USER: /home/linuxbrew/.linuxbrew
405-
406391
# install-hugo:
407392
# cmds:
408393
# # - /home/linuxbrew/.linuxbrew/bin/brew install hugo

prqlc/bindings/prqlc-python/Taskfile.yaml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,15 @@ vars:
55
venv_dir: "../../../target/venv"
66

77
tasks:
8-
fmt:
9-
desc: "Format"
10-
cmds:
11-
- black .
12-
- ruff check
13-
148
build:
159
desc: Build
1610
vars:
17-
mode: "debug"
11+
profile: "dev"
1812
cmds:
1913
- cmd: |
2014
maturin build \
21-
{{if eq .mode "release"}}--release{{end}} \
22-
-o {{.build_dir}} \
23-
-m Cargo.toml
15+
--profile={{.profile}} \
16+
--out={{.build_dir}}
2417
2518
init-venv:
2619
status:
@@ -34,8 +27,7 @@ tasks:
3427
cmds:
3528
- cmd: |
3629
source {{.venv_dir}}/bin/activate
37-
pip install {{.build_dir}}/prql_python-*.whl
38-
pip install -r requirements.txt
30+
pip install .[dev]
3931
- cmd: |
4032
source {{.venv_dir}}/bin/activate
41-
pytest
33+
python -m pytest

prqlc/bindings/prqlc-python/noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def _install_prqlc(session: Session) -> None:
2424
# plain pip of doing that (https://github.com/pypa/pip/issues/11440).
2525
# "--no-index",
2626
f"--find-links={Path('..', '..', '..', 'target', 'python')}",
27-
"prqlc[test]",
27+
"prqlc[dev]",
2828
)
2929

3030

prqlc/bindings/prqlc-python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ features = ["pyo3/extension-module"]
2525
module-name = "prqlc"
2626

2727
[project.optional-dependencies]
28-
test = [
28+
dev = [
2929
"pytest >= 7",
3030
"mypy == 1.10.0",
3131
]

prqlc/prqlc-parser/src/lexer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ pub fn lex_token() -> impl Parser<char, Token, Error = Cheap<char>> {
108108
just("internal"),
109109
just("func"),
110110
just("import"),
111+
just("enum"),
111112
))
112113
.then_ignore(end_expr())
113114
.map(|x| x.to_string())

prqlc/prqlc-parser/src/types.rs

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,25 +81,32 @@ pub fn type_expr() -> impl Parser<TokenKind, Ty, Error = PError> {
8181
.map(TyKind::Tuple)
8282
.labelled("tuple");
8383

84-
let union_parenthesized = ident_part()
85-
.then_ignore(ctrl('='))
86-
.or_not()
87-
.then(nested_type_expr.clone())
88-
.padded_by(new_line().repeated())
89-
.separated_by(just(TokenKind::Or))
90-
.allow_trailing()
91-
.then_ignore(new_line().repeated())
92-
.delimited_by(ctrl('('), ctrl(')'))
93-
.recover_with(nested_delimiters(
94-
TokenKind::Control('('),
95-
TokenKind::Control(')'),
96-
[
97-
(TokenKind::Control('{'), TokenKind::Control('}')),
98-
(TokenKind::Control('('), TokenKind::Control(')')),
99-
(TokenKind::Control('['), TokenKind::Control(']')),
100-
],
101-
|_| vec![],
102-
))
84+
let enum_ = keyword("enum")
85+
.ignore_then(
86+
ident_part()
87+
.then(ctrl('=').ignore_then(nested_type_expr.clone()).or_not())
88+
.map(|(name, ty)| {
89+
(
90+
Some(name),
91+
ty.unwrap_or_else(|| Ty::new(TyKind::Tuple(vec![]))),
92+
)
93+
})
94+
.padded_by(new_line().repeated())
95+
.separated_by(ctrl(','))
96+
.allow_trailing()
97+
.then_ignore(new_line().repeated())
98+
.delimited_by(ctrl('{'), ctrl('}'))
99+
.recover_with(nested_delimiters(
100+
TokenKind::Control('{'),
101+
TokenKind::Control('}'),
102+
[
103+
(TokenKind::Control('{'), TokenKind::Control('}')),
104+
(TokenKind::Control('('), TokenKind::Control(')')),
105+
(TokenKind::Control('['), TokenKind::Control(']')),
106+
],
107+
|_| vec![],
108+
)),
109+
)
103110
.map(TyKind::Union)
104111
.labelled("union");
105112

@@ -120,7 +127,7 @@ pub fn type_expr() -> impl Parser<TokenKind, Ty, Error = PError> {
120127
.map(TyKind::Array)
121128
.labelled("array");
122129

123-
let term = choice((basic, ident, func, tuple, array, union_parenthesized))
130+
let term = choice((basic, ident, func, tuple, array, enum_))
124131
.map_with_span(into_ty)
125132
.boxed();
126133

prqlc/prqlc/tests/integration/resolving.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ fn resolve_types_01() {
5959
#[test]
6060
fn resolve_types_02() {
6161
assert_snapshot!(resolve(r#"
62-
type A = int || ()
62+
type A = int || {}
6363
"#).unwrap(), @r###"
64-
type A = int
64+
type A = int || {}
6565
"###)
6666
}
6767

@@ -78,16 +78,15 @@ fn resolve_types_03() {
7878
fn resolve_types_04() {
7979
assert_snapshot!(resolve(
8080
r#"
81-
type Status = (
82-
Paid = () ||
83-
Unpaid = float ||
84-
Canceled = {reason = text, cancelled_at = timestamp} ||
85-
)
81+
type Status = enum {
82+
Paid = {},
83+
Unpaid = float,
84+
Canceled = {reason = text, cancelled_at = timestamp},
85+
}
8686
"#,
8787
)
8888
.unwrap(), @r###"
8989
type Status = (
90-
Paid = () ||
9190
Unpaid = float ||
9291
{reason = text, cancelled_at = timestamp} ||
9392
)

web/Taskfile.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ tasks:
1111
- cd book && mdbook build
1212
- mkdir -p website/public
1313
# Copy the book into the website path, using rsync so it only copies new files
14-
- rsync -ai --checksum --delete book/book/ website/public/book/
14+
- rsync -ai --checksum --delete --no-times book/book/ website/public/book/
1515
# (we don't use `build-playground-dependencies`, since that uses the dev profile)
1616
- cd playground && npm ci && npm run build
1717
# We place the playground app in a nested path, because we want to use
1818
# prql-lang.org/playground with an iframe containing the playground.
1919
# Possibly there's a more elegant way of doing this...
20-
- rsync -ai --checksum --delete playground/dist/
20+
- rsync -ai --checksum --delete --no-times playground/dist/
2121
website/public/playground/playground/
2222

2323
run-website:

0 commit comments

Comments
 (0)