Skip to content

Commit 997e338

Browse files
committed
Removing dataclass default values
1 parent 25fe97d commit 997e338

File tree

2 files changed

+37
-79
lines changed

2 files changed

+37
-79
lines changed

forte/data/ontology/top.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ class Link(BaseLink):
231231
"""
232232
# this type Any is needed since subclasses of this class will have new types
233233

234-
parent_type: Any = Entry
235-
child_type: Any = Entry
236-
parent: Optional[int] = None
237-
child: Optional[int] = None
234+
parent_type: Any
235+
child_type: Any
236+
parent: Optional[int]
237+
child: Optional[int]
238238

239239
ParentType = Entry
240240
ChildType = Entry
@@ -385,10 +385,10 @@ class MultiPackLink(MultiEntry, BaseLink):
385385
integers, one additional index on which pack it comes from.
386386
"""
387387

388-
parent_type: Any = Entry
389-
child_type: Any = Entry
390-
parent: Tuple = (None, None)
391-
child: Tuple = (None, None)
388+
parent_type: Any
389+
child_type: Any
390+
parent: Tuple
391+
child: Tuple
392392

393393
ParentType = Entry
394394
ChildType = Entry
@@ -519,8 +519,8 @@ class MultiPackGroup(MultiEntry, BaseGroup[Entry]):
519519
r"""Group type entries, such as "coreference group". Each group has a set
520520
of members.
521521
"""
522-
member_type: Type[Entry] = Entry
523-
members: Optional[FList[Entry]] = None
522+
member_type: Type[Entry]
523+
members: Optional[FList[Entry]]
524524

525525
MemberType = Entry
526526

@@ -1018,7 +1018,7 @@ class Payload(Entry):
10181018

10191019
payload_idx: int
10201020
modality_name: str
1021-
uri: Optional[str] = None
1021+
uri: Optional[str]
10221022

10231023
def __init__(
10241024
self,

ft/onto/base_ontology.py

+26-68
Original file line numberDiff line numberDiff line change
@@ -317,17 +317,12 @@ class PredicateLink(Link):
317317
arg_type (Optional[str]): The predicate link type.
318318
"""
319319

320-
arg_type: Optional[str] = None
320+
arg_type: Optional[str]
321321

322322
ParentType = PredicateMention
323323
ChildType = PredicateArgument
324324

325-
def __init__(
326-
self,
327-
pack: DataPack,
328-
parent: Optional[Entry] = None,
329-
child: Optional[Entry] = None,
330-
):
325+
def __init__(self, pack: DataPack, parent: Optional[Entry] = None, child: Optional[Entry] = None):
331326
super().__init__(pack, parent, child)
332327
self.arg_type: Optional[str] = None
333328

@@ -341,18 +336,13 @@ class Dependency(Link):
341336
rel_type (Optional[str]):
342337
"""
343338

344-
dep_label: Optional[str] = None
345-
rel_type: Optional[str] = None
339+
dep_label: Optional[str]
340+
rel_type: Optional[str]
346341

347342
ParentType = Token
348343
ChildType = Token
349344

350-
def __init__(
351-
self,
352-
pack: DataPack,
353-
parent: Optional[Entry] = None,
354-
child: Optional[Entry] = None,
355-
):
345+
def __init__(self, pack: DataPack, parent: Optional[Entry] = None, child: Optional[Entry] = None):
356346
super().__init__(pack, parent, child)
357347
self.dep_label: Optional[str] = None
358348
self.rel_type: Optional[str] = None
@@ -361,23 +351,18 @@ def __init__(
361351
@dataclass
362352
class EnhancedDependency(Link):
363353
"""
364-
A `Link` type entry which represent a enhanced dependency:
354+
A `Link` type entry which represent a enhanced dependency:
365355
https://universaldependencies.org/u/overview/enhanced-syntax.html
366356
Attributes:
367357
dep_label (Optional[str]): The enhanced dependency label in Universal Dependency.
368358
"""
369359

370-
dep_label: Optional[str] = None
360+
dep_label: Optional[str]
371361

372362
ParentType = Token
373363
ChildType = Token
374364

375-
def __init__(
376-
self,
377-
pack: DataPack,
378-
parent: Optional[Entry] = None,
379-
child: Optional[Entry] = None,
380-
):
365+
def __init__(self, pack: DataPack, parent: Optional[Entry] = None, child: Optional[Entry] = None):
381366
super().__init__(pack, parent, child)
382367
self.dep_label: Optional[str] = None
383368

@@ -390,17 +375,12 @@ class RelationLink(Link):
390375
rel_type (Optional[str]): The type of the relation.
391376
"""
392377

393-
rel_type: Optional[str] = None
378+
rel_type: Optional[str]
394379

395380
ParentType = EntityMention
396381
ChildType = EntityMention
397382

398-
def __init__(
399-
self,
400-
pack: DataPack,
401-
parent: Optional[Entry] = None,
402-
child: Optional[Entry] = None,
403-
):
383+
def __init__(self, pack: DataPack, parent: Optional[Entry] = None, child: Optional[Entry] = None):
404384
super().__init__(pack, parent, child)
405385
self.rel_type: Optional[str] = None
406386

@@ -413,17 +393,12 @@ class CrossDocEntityRelation(MultiPackLink):
413393
rel_type (Optional[str]): The type of the relation.
414394
"""
415395

416-
rel_type: Optional[str] = None
396+
rel_type: Optional[str]
417397

418398
ParentType = EntityMention
419399
ChildType = EntityMention
420400

421-
def __init__(
422-
self,
423-
pack: MultiPack,
424-
parent: Optional[Entry] = None,
425-
child: Optional[Entry] = None,
426-
):
401+
def __init__(self, pack: MultiPack, parent: Optional[Entry] = None, child: Optional[Entry] = None):
427402
super().__init__(pack, parent, child)
428403
self.rel_type: Optional[str] = None
429404

@@ -436,9 +411,7 @@ class CoreferenceGroup(Group):
436411

437412
MemberType = EntityMention
438413

439-
def __init__(
440-
self, pack: DataPack, members: Optional[Iterable[Entry]] = None
441-
):
414+
def __init__(self, pack: DataPack, members: Optional[Iterable[Entry]] = None):
442415
super().__init__(pack, members)
443416

444417

@@ -450,17 +423,12 @@ class EventRelation(Link):
450423
rel_type (Optional[str]): The type of the relation.
451424
"""
452425

453-
rel_type: Optional[str] = None
426+
rel_type: Optional[str]
454427

455428
ParentType = EventMention
456429
ChildType = EventMention
457430

458-
def __init__(
459-
self,
460-
pack: DataPack,
461-
parent: Optional[Entry] = None,
462-
child: Optional[Entry] = None,
463-
):
431+
def __init__(self, pack: DataPack, parent: Optional[Entry] = None, child: Optional[Entry] = None):
464432
super().__init__(pack, parent, child)
465433
self.rel_type: Optional[str] = None
466434

@@ -473,17 +441,12 @@ class CrossDocEventRelation(MultiPackLink):
473441
rel_type (Optional[str]): The type of the relation.
474442
"""
475443

476-
rel_type: Optional[str] = None
444+
rel_type: Optional[str]
477445

478446
ParentType = EventMention
479447
ChildType = EventMention
480448

481-
def __init__(
482-
self,
483-
pack: MultiPack,
484-
parent: Optional[Entry] = None,
485-
child: Optional[Entry] = None,
486-
):
449+
def __init__(self, pack: MultiPack, parent: Optional[Entry] = None, child: Optional[Entry] = None):
487450
super().__init__(pack, parent, child)
488451
self.rel_type: Optional[str] = None
489452

@@ -505,17 +468,17 @@ class ConstituentNode(Annotation):
505468
sentiment: Dict[str, float]
506469
is_root: Optional[bool]
507470
is_leaf: Optional[bool]
508-
parent_node: Optional["ConstituentNode"]
509-
children_nodes: FList["ConstituentNode"]
471+
parent_node: Optional['ConstituentNode']
472+
children_nodes: FList['ConstituentNode']
510473

511474
def __init__(self, pack: DataPack, begin: int, end: int):
512475
super().__init__(pack, begin, end)
513476
self.label: Optional[str] = None
514477
self.sentiment: Dict[str, float] = dict()
515478
self.is_root: Optional[bool] = None
516479
self.is_leaf: Optional[bool] = None
517-
self.parent_node: Optional["ConstituentNode"] = None
518-
self.children_nodes: FList["ConstituentNode"] = FList(self)
480+
self.parent_node: Optional['ConstituentNode'] = None
481+
self.children_nodes: FList['ConstituentNode'] = FList(self)
519482

520483

521484
@dataclass
@@ -540,6 +503,7 @@ def __init__(self, pack: DataPack, begin: int, end: int):
540503

541504
@dataclass
542505
class MCOption(Annotation):
506+
543507
def __init__(self, pack: DataPack, begin: int, end: int):
544508
super().__init__(pack, begin, end)
545509

@@ -617,11 +581,9 @@ class AudioPayload(Payload):
617581
sample_rate (Optional[int]):
618582
"""
619583

620-
sample_rate: Optional[int] = None
584+
sample_rate: Optional[int]
621585

622-
def __init__(
623-
self, pack: DataPack, payload_idx: int = 0, uri: Optional[str] = None
624-
):
586+
def __init__(self, pack: DataPack, payload_idx: int = 0, uri: Optional[str] = None):
625587
super().__init__(pack, payload_idx, uri)
626588
self.sample_rate: Optional[int] = None
627589

@@ -632,9 +594,7 @@ class TextPayload(Payload):
632594
A payload that caches text data
633595
"""
634596

635-
def __init__(
636-
self, pack: DataPack, payload_idx: int = 0, uri: Optional[str] = None
637-
):
597+
def __init__(self, pack: DataPack, payload_idx: int = 0, uri: Optional[str] = None):
638598
super().__init__(pack, payload_idx, uri)
639599

640600

@@ -644,7 +604,5 @@ class ImagePayload(Payload):
644604
A payload that caches image data
645605
"""
646606

647-
def __init__(
648-
self, pack: DataPack, payload_idx: int = 0, uri: Optional[str] = None
649-
):
607+
def __init__(self, pack: DataPack, payload_idx: int = 0, uri: Optional[str] = None):
650608
super().__init__(pack, payload_idx, uri)

0 commit comments

Comments
 (0)