Skip to content

Commit

Permalink
feat: Add reset and copy methods to datatypes
Browse files Browse the repository at this point in the history
This change adds a `reset()` method to the `AtomicField`, `SimpleField`, `Coordenadas`, and `GerarPlai` datatypes. The `reset()` method removes the `value` attribute from the instance, allowing it to be reused. Additionally, a `copy()` method has been added to return a new instance of the datatype.
  • Loading branch information
ronaldokun committed Aug 6, 2024
1 parent c4fedf4 commit f799ff6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions fiscaliza/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class AtomicField:
keyword: str
mandatory: bool = True

def init(self):
def reset(self):
if hasattr(self, "value"):
del self.value
return self
return self.copy()

@property
def dtype(self):
Expand Down Expand Up @@ -61,10 +61,10 @@ class SimpleField:
format_value: bool = False
_dtype: str = "string"

def init(self):
def reset(self):
if hasattr(self, "value"):
del self.value
return self
return self.copy()

@property
def dtype(self):
Expand Down Expand Up @@ -197,10 +197,10 @@ class Coordenadas:
name: str
mandatory: bool = False

def init(self):
def reset(self):
if hasattr(self, "value"):
del self.value
return self
return self.copy()

@cached_property
def value(self):
Expand Down Expand Up @@ -244,10 +244,10 @@ class GerarPlai:
CODES = ["100000539", "100000618"]
options = list(product(TIPO_DE_PROCESSO, COORD_FI))

def init(self):
def reset(self):
if hasattr(self, "value"):
del self.value
return self
return self.copy()

@cached_property
def value(self):
Expand Down

0 comments on commit f799ff6

Please sign in to comment.