Skip to content

feat: warn if unexpected-error-in-is_valid_syntax - #51

Merged
jkowalleck merged 8 commits into
mainfrom
feat/warn-if-unexpected-error-in-is_valid_syntax
Jul 20, 2026
Merged

jkowalleck merged 8 commits into
mainfrom
feat/warn-if-unexpected-error-in-is_valid_syntax

Conversation

@jkowalleck

@jkowalleck jkowalleck commented Jul 20, 2026 •

Copy link
Copy Markdown
Collaborator

Function is_valid_syntax issues a warning if an unexpected error occurred

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
@jkowalleck jkowalleck added the enhancement New feature or request label Jul 20, 2026
@jkowalleck

Copy link
Copy Markdown
Collaborator Author

@copilot add a new file that tests that the new warning is thorw.

jkowalleck and others added 3 commits July 20, 2026 19:56
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
…thub.com:jkowalleck/rfc3987-syntax2 into feat/warn-if-unexpected-error-in-is_valid_syntax

Copilot AI commented Jul 20, 2026 •

Copy link
Copy Markdown

@copilot add a new file that tests that the new warning is thorw.

Added tests/test_is_valid_syntax_warning.py in commit $(git -C /home/runner/work/rfc3987-syntax2/rfc3987-syntax2 rev-parse --short HEAD). It patches parse to raise a plain LarkError and asserts that is_valid_syntax emits a RuntimeWarning and returns False, covering all three valid term values (iri, iri_reference, absolute_iri).

@copilot add a new file that tests that the new warning is thorw.

Added tests/test_is_valid_syntax_warning.py in commit 0a3e845. It patches parse to raise a plain LarkError and asserts that is_valid_syntax emits a RuntimeWarning matching "Unexpected LarkError" and returns False, covering all three valid term values (iri, iri_reference, absolute_iri).

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a warning path to the RFC3987 syntax validation helpers so consumers can distinguish between “invalid syntax” and “unexpected internal Lark error” scenarios.

Changes:

  • Update is_valid_syntax() to return False for UnexpectedInput without warning, and warn+return False for other LarkError subclasses.
  • Add a regression test ensuring a RuntimeWarning is emitted for non-UnexpectedInput LarkErrors.
  • Document the behavior change in the Unreleased changelog.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
tests/test_is_valid_syntax_warning.py Adds test coverage for warning behavior on unexpected LarkError.
src/rfc3987_syntax2/syntax_helpers.py Implements warning behavior for unexpected Lark errors; adjusts validator exception handling.
CHANGELOG.md Notes the new warning behavior for is_valid_syntax().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/rfc3987_syntax2/syntax_helpers.py
Comment thread src/rfc3987_syntax2/syntax_helpers.py Outdated
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
@jkowalleck
jkowalleck merged commit 356d527 into main Jul 20, 2026
21 checks passed
@jkowalleck
jkowalleck deleted the feat/warn-if-unexpected-error-in-is_valid_syntax branch July 20, 2026 18:11
@jkowalleck

Copy link
Copy Markdown
Collaborator Author

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants