Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking: Rename [SomeCode]ParserError to [SomeCode]ParseError and inherit from SyntaxError #3140

Merged
merged 1 commit into from Jul 10, 2023

Conversation

janosh
Copy link
Member

@janosh janosh commented Jul 10, 2023

By making all ParseError classes inherit from the new pymatgen.io.core.ParseError (used to be generic Exception) which subclasses SyntaxError, ParseErrors can now add line numbers and filenames to errors:

class SyntaxError(Exception):
    msg: str
    lineno: int | None
    offset: int | None
    text: str | None
    filename: str | None
    if sys.version_info >= (3, 10):
        end_lineno: int | None
        end_offset: int | None

make all ParseError classes inherit from pymatgen.io.core.ParseError which is a SyntaxError subclass. allows for adding line numbers and filenames to errors

class SyntaxError(Exception):
    msg: str
    lineno: int | None
    offset: int | None
    text: str | None
    filename: str | None
    if sys.version_info >= (3, 10):
        end_lineno: int | None
        end_offset: int | None
@janosh janosh added io Input/output functionality breaking Breaking change dx Developer experience labels Jul 10, 2023
@janosh janosh changed the title Breaking: Rename [SomeCode]ParserError to [SomeTool]ParseError and inherit from SyntaxError Breaking: Rename [SomeCode]ParserError to [SomeCode]ParseError and inherit from SyntaxError Jul 10, 2023
@janosh janosh merged commit 5b88fc1 into master Jul 10, 2023
41 checks passed
@janosh janosh deleted the io-core-parse-error-cls branch July 10, 2023 20:18
janosh added a commit that referenced this pull request Jul 11, 2023
make all ParseError classes inherit from pymatgen.io.core.ParseError which is a SyntaxError subclass. allows for adding line numbers and filenames to errors

class SyntaxError(Exception):
    msg: str
    lineno: int | None
    offset: int | None
    text: str | None
    filename: str | None
    if sys.version_info >= (3, 10):
        end_lineno: int | None
        end_offset: int | None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Breaking change dx Developer experience io Input/output functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant