Skip to content

Conversation

@tatiana-s
Copy link
Contributor

Closes #1209 (to be merged into protocol-main as the clean protocols work in progress branch)

@tatiana-s tatiana-s requested a review from a team as a code owner September 24, 2025 07:50
@github-actions
Copy link
Contributor

github-actions bot commented Sep 24, 2025

🐰 Bencher Report

Branchparsing
TestbedLinux
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
microseconds (µs)
(Result Δ%)
Upper Boundary
microseconds (µs)
(Limit %)
tests/benchmarks/test_big_array.py::test_big_array_check📈 view plot
🚷 view threshold
621,165.06 µs
(0.00%)Baseline: 621,165.06 µs
652,223.32 µs
(95.24%)
tests/benchmarks/test_big_array.py::test_big_array_compile📈 view plot
🚷 view threshold
3,159,021.44 µs
(0.00%)Baseline: 3,159,021.44 µs
3,316,972.51 µs
(95.24%)
tests/benchmarks/test_big_array.py::test_big_array_executable📈 view plot
🚷 view threshold
9,122,793.06 µs
(0.00%)Baseline: 9,122,793.06 µs
9,578,932.71 µs
(95.24%)
tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_check📈 view plot
🚷 view threshold
45,857.28 µs
(0.00%)Baseline: 45,857.28 µs
48,150.14 µs
(95.24%)
tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_compile📈 view plot
🚷 view threshold
87,378.94 µs
(0.00%)Baseline: 87,378.94 µs
91,747.89 µs
(95.24%)
tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_executable📈 view plot
🚷 view threshold
674,534.66 µs
(0.00%)Baseline: 674,534.66 µs
708,261.39 µs
(95.24%)
tests/benchmarks/test_prelude.py::test_import_guppy📈 view plot
🚷 view threshold
24.45 µs
(0.00%)Baseline: 24.45 µs
25.68 µs
(95.24%)
🐰 View full continuous benchmarking report in Bencher

@github-actions
Copy link
Contributor

github-actions bot commented Sep 24, 2025

🐰 Bencher Report

Branchparsing
TestbedLinux
Click to view all benchmark results
Benchmarkhugr_bytesBenchmark Result
bytes x 1e3
(Result Δ%)
Upper Boundary
bytes x 1e3
(Limit %)
hugr_nodesBenchmark Result
nodes
(Result Δ%)
Upper Boundary
nodes
(Limit %)
tests/benchmarks/test_big_array.py::test_big_array_compile📈 view plot
🚷 view threshold
129.06 x 1e3
(0.00%)Baseline: 129.06 x 1e3
130.36 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
4,873.00
(0.00%)Baseline: 4,873.00
4,921.73
(99.01%)
tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_compile📈 view plot
🚷 view threshold
21.99 x 1e3
(0.00%)Baseline: 21.99 x 1e3
22.21 x 1e3
(99.01%)
📈 view plot
🚷 view threshold
693.00
(0.00%)Baseline: 693.00
699.93
(99.01%)
🐰 View full continuous benchmarking report in Bencher

@codecov-commenter
Copy link

codecov-commenter commented Sep 24, 2025

Codecov Report

❌ Patch coverage is 81.98198% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.39%. Comparing base (56d57b3) to head (1171ad2).

Files with missing lines Patch % Lines
...als/src/guppylang_internals/definition/protocol.py 77.38% 19 Missing ⚠️
guppylang/src/guppylang/decorator.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##           protocol-main    #1275      +/-   ##
=================================================
- Coverage          93.50%   93.39%   -0.12%     
=================================================
  Files                121      123       +2     
  Lines              11168    11279     +111     
=================================================
+ Hits               10443    10534      +91     
- Misses               725      745      +20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines +94 to +95
# Specifying `Protocol` is redundant but we allow it optionally.
case [base] if isinstance(base, ast.Name) and base.id == "Protocol":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python also allows specifying legacy generic parameters via a Protocol[T] base: https://typing.python.org/en/latest/spec/protocol.html#generic-protocols

Do we also want this?

frame = DEF_STORE.frames[self.id]
cls_def = parse_py_class(self.python_class, frame, sources)
if cls_def.keywords:
raise GuppyError(UnexpectedError(cls_def.keywords[0], "keyword"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test that triggers this error?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for the other errors in this file without coverage

Comment on lines +112 to +113
if not isinstance(v, GuppyDefinition):
raise GuppyError(NonGuppyMethodError(node, self.name, name))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually want to require @guppy.declare annotations on protocol methods? We could also leave them unannotated and parse them here?

Comment on lines +180 to +184
# Prior to Python 3.13, the `__firstlineno__` attribute on classes is not set.
# However, we need this information to precisely look up the source for the
# class later. If it's not there, we can set it from the calling frame:
if not hasattr(cls, "__firstlineno__"):
cls.__firstlineno__ = frame.f_lineno # type: ignore[attr-defined]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is obscure enough that it might be worth putting into a helper function now that we have this twice

3 | @guppy.protocol
4 | class MyProto:
5 | id: int
| ^^^^^^^ fields are not supported in a protocol definition
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: should be capitalised to be consistent with other errors

6 | class MyProto(Protocol):
| ^^^^^^^^ Protocol base is not supported

Help: Add a `@guppy.protocol` annotation to turn this struct into a protocol
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants