Skip to content

Commit d2af40a

Browse files
authored
Merge pull request #276 from fonttools/guideline-default-values
Bring guideline invariants up to spec
2 parents 4d8a960 + 2345412 commit d2af40a

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
file: coverage.xml
7272
flags: unittests
7373
name: codecov-umbrella
74-
fail_ci_if_error: true
74+
fail_ci_if_error: false
7575

7676
deploy:
7777
# only run if the commit is tagged...

src/ufoLib2/objects/guideline.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ class Guideline(AttrDictMixin):
1717
data composition restrictions.
1818
"""
1919

20-
x: Optional[float] = None
20+
x: float = 0
2121
"""The origin x coordinate of the guideline."""
2222

23-
y: Optional[float] = None
23+
y: float = 0
2424
"""The origin y coordinate of the guideline."""
2525

26-
angle: Optional[float] = None
26+
angle: float = 0
2727
"""The angle of the guideline."""
2828

2929
name: Optional[str] = None
@@ -36,13 +36,5 @@ class Guideline(AttrDictMixin):
3636
"""The globally unique identifier of the guideline."""
3737

3838
def __attrs_post_init__(self) -> None:
39-
x, y, angle = self.x, self.y, self.angle
40-
if x is None and y is None:
41-
raise ValueError("x or y must be present")
42-
if x is None or y is None:
43-
if angle is not None:
44-
raise ValueError("if 'x' or 'y' are None, 'angle' must not be present")
45-
if x is not None and y is not None and angle is None:
46-
raise ValueError("if 'x' and 'y' are defined, 'angle' must be defined")
47-
if angle is not None and not (0 <= angle <= 360):
39+
if not (0 <= self.angle <= 360):
4840
raise ValueError("angle must be between 0 and 360")

tests/test_converters.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@
110110
],
111111
},
112112
),
113-
(Guideline(x=0, name="foo"), {"x": 0, "name": "foo"}),
113+
(Guideline(x=0, name="foo"), {"name": "foo"}),
114+
(
115+
Guideline(x=149, y=1523, identifier="aaa"),
116+
{"x": 149, "y": 1523, "identifier": "aaa"},
117+
),
114118
(Guideline(y=1, name="bar"), {"y": 1, "name": "bar"}),
115119
(
116120
Guideline(

0 commit comments

Comments
 (0)