Skip to content

Commit

Permalink
Make empty identifiers a fatal error
Browse files Browse the repository at this point in the history
Ref. #892
  • Loading branch information
Alexander Senier committed Jan 5, 2022
1 parent 8dc0e4f commit a46bef2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions rflx/identifier.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
from typing import Optional, Sequence, TypeVar, Union

from rflx.error import Location, RecordFluxError, Severity, Subsystem
from rflx.error import Location, RecordFluxError, Severity, Subsystem, fatal_fail

Self = TypeVar("Self", bound="ID")

Expand All @@ -25,7 +25,7 @@ def __init__(

error = RecordFluxError()
if not self._parts:
error.extend([("empty identifier", Subsystem.ID, Severity.ERROR, location)])
fatal_fail("empty identifier", Subsystem.ID, Severity.ERROR, location)
elif "" in self._parts:
error.extend(
[(f'empty part in identifier "{self}"', Subsystem.ID, Severity.ERROR, location)]
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/identifier_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from rflx.error import RecordFluxError
from rflx.error import FatalError, RecordFluxError
from rflx.identifier import ID


Expand All @@ -20,7 +20,7 @@ def test_id_invalid_type() -> None:


def test_id_invalid_empty() -> None:
with pytest.raises(RecordFluxError, match=r"^id: error: empty identifier$"):
with pytest.raises(FatalError, match=r"^id: error: empty identifier$"):
ID([])


Expand Down Expand Up @@ -107,7 +107,7 @@ def test_id_parent() -> None:


def test_id_parent_error() -> None:
with pytest.raises(RecordFluxError, match=r"^id: error: empty identifier$"):
with pytest.raises(FatalError, match=r"^id: error: empty identifier$"):
ID("A").parent # pylint: disable=expression-not-assigned


Expand Down

0 comments on commit a46bef2

Please sign in to comment.