Sep-05-2021, 10:18 AM
(This post was last modified: Sep-05-2021, 10:18 AM by WannaBePythonDev.)
(Sep-04-2021, 10:08 PM)Larz60+ Wrote: when posting errors, please, always post the entire, unaltered error traceback as it contains valuable diagnostic information.
Error:{
"resource": "~/Intro to Logic/Projects/propositions/syntax.py",
"owner": "python",
"code": "error",
"severity": 8,
"message": "Argument 1 to \"formula_obj_to_string\" of \"Formula\" has incompatible type \"Optional[Formula]\"; expected \"Formula\"",
"source": "mypy",
"startLineNumber": 134,
"startColumn": 61,
"endLineNumber": 134,
"endColumn": 61
}
{
"resource": "~/Intro to Logic/Projects/propositions/syntax.py",
"owner": "python",
"code": "error",
"severity": 8,
"message": "Argument 2 to \"create_binary_formula\" of \"Formula\" has incompatible type \"Optional[Formula]\"; expected \"Formula\"",
"source": "mypy",
"startLineNumber": 175,
"startColumn": 31,
"endLineNumber": 175,
"endColumn": 31
}
{
"resource": "~/Intro to Logic/Projects/propositions/syntax.py",
"owner": "python",
"code": "error",
"severity": 8,
"message": "Argument 3 to \"create_binary_formula\" of \"Formula\" has incompatible type \"Optional[Formula]\"; expected \"Formula\"",
"source": "mypy",
"startLineNumber": 175,
"startColumn": 46,
"endLineNumber": 175,
"endColumn": 46
}
@staticmethod def negate_formula(formula: Formula) -> str: """Negates a formula. Parameters: formula: A formula to negate. Returns: A string reresenting the formula negated. """ return formula.root + Formula.formula_obj_to_string(formula.first)
@staticmethod def create_binary_formula( binary_operator: str, first_sub_formula: Formula, second_sub_formula: Formula ) -> str: """Assmebles a binary formula out of two sub-formulas. Parameters: binary_operator: The binary operator applied on the two sub-formulas. first_sub_formula: The first sub-formula. second_sub_formula: The second sub-formula. Returns: A string reresenting the suitable binary formula. """ return ( OPEN_BINARY_FORM + Formula.formula_obj_to_string(first_sub_formula) + binary_operator + Formula.formula_obj_to_string(second_sub_formula) + CLOSE_BINARY_FORM )This is all the related stuff.