-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update top-level definitions to use new diagnostics (#604)
- Loading branch information
Showing
37 changed files
with
461 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from dataclasses import dataclass | ||
from typing import ClassVar | ||
|
||
from guppylang.diagnostic import Error | ||
|
||
|
||
@dataclass(frozen=True) | ||
class UnsupportedError(Error): | ||
title: ClassVar[str] = "Unsupported" | ||
span_label: ClassVar[str] = "{things} {is_are} not supported{extra}" | ||
things: str | ||
singular: bool = False | ||
unsupported_in: str = "" | ||
|
||
@property | ||
def is_are(self) -> str: | ||
return "is" if self.singular else "are" | ||
|
||
@property | ||
def extra(self) -> str: | ||
return f" in {self.unsupported_in}" if self.unsupported_in else "" | ||
|
||
|
||
@dataclass(frozen=True) | ||
class UnexpectedError(Error): | ||
title: ClassVar[str] = "Unexpected {things}" | ||
span_label: ClassVar[str] = "Unexpected {things}{extra}" | ||
things: str | ||
unexpected_in: str = "" | ||
|
||
@property | ||
def extra(self) -> str: | ||
return f" in {self.unexpected_in}" if self.unexpected_in else "" | ||
|
||
|
||
@dataclass(frozen=True) | ||
class ExpectedError(Error): | ||
title: ClassVar[str] = "Expected {things}" | ||
span_label: ClassVar[str] = "Expected {things}{extra}" | ||
things: str | ||
got: str = "" | ||
|
||
@property | ||
def extra(self) -> str: | ||
return f", got {self.got}" if self.got else "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.