Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d443677

Browse filesBrowse files
committed
add star pattern
1 parent b5efb7a commit d443677
Copy full SHA for d443677

File tree

5 files changed

+19
-18
lines changed
Filter options

5 files changed

+19
-18
lines changed

‎.github/workflows/test.yaml

Copy file name to clipboardExpand all lines: .github/workflows/test.yaml
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Install Python Dependencies
2121
run: pip install -r requirements/nox-deps.txt
2222
- name: Run Tests
23-
run: nox -s test
23+
run: nox -t test
2424

2525
environments:
2626
runs-on: ubuntu-latest
@@ -36,4 +36,4 @@ jobs:
3636
- name: Install Python Dependencies
3737
run: pip install -r requirements/nox-deps.txt
3838
- name: Run Tests
39-
run: nox -s test -- --no-cov
39+
run: nox -t test -- --no-cov

‎noxfile.py

Copy file name to clipboardExpand all lines: noxfile.py
+5-12Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,26 @@
88

99
@session
1010
def format(session: Session) -> None:
11-
install_requirements(session, "style")
11+
install_requirements(session, "check-style")
1212
session.run("black", ".")
1313
session.run("isort", ".")
1414

1515

16-
@session
17-
def test(session: Session) -> None:
18-
session.notify("test_style")
19-
session.notify("test_types")
20-
session.notify("test_suite")
21-
22-
23-
@session
16+
@session(tags=["test"])
2417
def test_style(session: Session) -> None:
2518
install_requirements(session, "check-style")
2619
session.run("black", "--check", ".")
2720
session.run("isort", "--check", ".")
2821
session.run("flake8", ".")
2922

3023

31-
@session
24+
@session(tags=["test"])
3225
def test_types(session: Session) -> None:
3326
install_requirements(session, "check-types")
3427
session.run("mypy", "--strict", "reactpy_router")
3528

3629

37-
@session
30+
@session(tags=["test"])
3831
def test_suite(session: Session) -> None:
3932
install_requirements(session, "test-env")
4033
session.run("playwright", "install", "chromium")
@@ -52,7 +45,7 @@ def test_suite(session: Session) -> None:
5245
session.run("pytest", "tests", *posargs)
5346

5447

55-
@session
48+
@session(tags=["test"])
5649
def test_javascript(session: Session) -> None:
5750
session.chdir(ROOT / "js")
5851
session.run("npm", "install", external=True)

‎reactpy_router/core.py

Copy file name to clipboardExpand all lines: reactpy_router/core.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from reactpy import (
99
component,
1010
create_context,
11+
html,
1112
use_context,
1213
use_location,
1314
use_memo,
@@ -18,7 +19,6 @@
1819
from reactpy.core.types import VdomChild, VdomDict
1920
from reactpy.types import ComponentType, Context, Location
2021
from reactpy.web.module import export, module_from_file
21-
from reactpy import html
2222

2323
from reactpy_router.types import Route, RouteCompiler, Router, RouteResolver
2424

@@ -42,7 +42,7 @@ def wrapper(*routes: R) -> ComponentType:
4242
def router_component(
4343
*routes: R,
4444
compiler: RouteCompiler[R],
45-
) -> ComponentType | None:
45+
) -> VdomDict | None:
4646
old_conn = use_connection()
4747
location, set_location = use_state(old_conn.location)
4848

‎reactpy_router/simple.py

Copy file name to clipboardExpand all lines: reactpy_router/simple.py
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
ConversionFunc: TypeAlias = "Callable[[str], Any]"
1515
ConverterMapping: TypeAlias = "dict[str, ConversionFunc]"
1616

17-
PARAM_REGEX = re.compile(r"{(?P<name>\w+)(?P<type>:\w+)?}")
17+
STAR_PATTERN = re.compile(".*")
18+
PARAM_PATTERN = re.compile(r"{(?P<name>\w+)(?P<type>:\w+)?}")
1819

1920

2021
class SimpleResolver:
@@ -34,10 +35,13 @@ def resolve(self, path: str) -> tuple[Any, dict[str, Any]] | None:
3435

3536

3637
def parse_path(path: str) -> tuple[re.Pattern[str], ConverterMapping]:
38+
if path == "*":
39+
return STAR_PATTERN, {}
40+
3741
pattern = "^"
3842
last_match_end = 0
3943
converters: ConverterMapping = {}
40-
for match in PARAM_REGEX.finditer(path):
44+
for match in PARAM_PATTERN.finditer(path):
4145
param_name = match.group("name")
4246
param_type = (match.group("type") or "str").lstrip(":")
4347
try:

‎tests/test_simple.py

Copy file name to clipboardExpand all lines: tests/test_simple.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,7 @@ def test_parse_path_re_escape():
4848
re.compile(r"^/a/(?P<b>\d+)/c\.d$"),
4949
{"b": int},
5050
)
51+
52+
53+
def test_parse_path_star():
54+
assert parse_path("*") == (re.compile("^.*$"), {})

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.