Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mypy typing error
#3
(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.
Reply


Messages In This Thread
Mypy typing error - by WannaBePythonDev - Sep-04-2021, 05:52 PM
RE: Mypy typing error - by Larz60+ - Sep-04-2021, 10:08 PM
RE: Mypy typing error - by WannaBePythonDev - Sep-05-2021, 10:18 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  mypy, type aliases and type variables tomciodev 1 705 Oct-18-2023, 10:08 AM
Last Post: Larz60+
Question mypy unable to analyse types of tuple elements in a list comprehension tomciodev 1 481 Oct-17-2023, 09:46 AM
Last Post: tomciodev
  problem in using mypy akbarza 17 3,051 Sep-06-2023, 01:53 PM
Last Post: snippsat
  Pywinauto typing in the wrong field EGameiro 0 682 Jun-07-2023, 10:01 PM
Last Post: EGameiro
  Typing and variable initializers jgossage 0 1,630 May-29-2020, 03:18 PM
Last Post: jgossage
  Need Help Typing Text into Tough Form [xpath / selenium] digitalmatic7 0 1,760 Jun-05-2019, 06:46 AM
Last Post: digitalmatic7
  Is there any way to simulate clicks/typing to an inactive window using Python? Nwb 1 5,929 Jun-11-2018, 08:56 AM
Last Post: Larz60+
  Typing into CMD Prompt while its behind another window andy410 0 2,536 Apr-27-2018, 08:24 PM
Last Post: andy410

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020