Skip to content

Commit

Permalink
chg: remove unnecessary re-validation of question type
Browse files Browse the repository at this point in the history
- type is checked during __init__, and it shouldn't change after that
  • Loading branch information
lindsay-stevens committed Jan 9, 2025
1 parent 578265d commit d5ba008
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions pyxform/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ def __init__(self, fields: tuple[str, ...] | None = None, **kwargs):

qtd = kwargs.pop("question_type_dictionary", QUESTION_TYPE_DICT)
type_arg = kwargs.get("type")
default_type = qtd.get(type_arg)
if default_type is None:
if type_arg not in qtd:
raise PyXFormError(f"Unknown question type '{type_arg}'.")

# Keeping original qtd_kwargs is only needed if output of QTD data is not
Expand Down Expand Up @@ -139,14 +138,6 @@ def __init__(self, fields: tuple[str, ...] | None = None, **kwargs):
fields = chain(QUESTION_EXTRA_FIELDS, fields)
super().__init__(fields=fields, **kwargs)

def validate(self):
SurveyElement.validate(self)

# make sure that the type of this question exists in the
# question type dictionary.
if self.type not in QUESTION_TYPE_DICT:
raise PyXFormError(f"Unknown question type '{self.type}'.")

def xml_instance(self, survey: "Survey", **kwargs):
if self.default and not default_is_dynamic(self.default, self.type):
result = node(self.name, str(self.default))
Expand Down

0 comments on commit d5ba008

Please sign in to comment.