Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix static typing errors #187

Merged
merged 10 commits into from
Jan 29, 2024
Merged

Fix static typing errors #187

merged 10 commits into from
Jan 29, 2024

Conversation

gvieira
Copy link
Collaborator

@gvieira gvieira commented Jan 27, 2024

Let's make sure we are at zero-errors as soon as possible!

Remember, today's ⚠️ is tomorrow's ❗, and next week's 🐛.

Previous logs
/Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py:50:16 - error: Expression of type "(self: object) -> int" cannot be assigned to declared type "None"
    Type cannot be assigned to type "None" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py:97:13 - error: No parameter named "model_name" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py:124:36 - error: Argument of type "InstanceOf[CacheHandler] | None" cannot be assigned to parameter "cache_handler" of type "CacheHandler" in function "set_cache_handler"
    Type "InstanceOf[CacheHandler] | None" cannot be assigned to type "CacheHandler"
      Type "None" cannot be assigned to type "CacheHandler" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py:144:30 - error: "slice" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py:149:29 - error: "tools" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py:151:38 - error: "invoke" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py:157:39 - error: Argument of type "list[InstanceOf[ToolsHandler] | None]" cannot be assigned to parameter "callbacks" of type "Callbacks" in function "__init__"
    Type "InstanceOf[ToolsHandler] | None" cannot be assigned to type "BaseCallbackHandler"
      Type "None" cannot be assigned to type "BaseCallbackHandler" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py:212:21 - error: Argument of type "Any | None" cannot be assigned to parameter "llm" of type "BaseLanguageModel[Unknown]" in function "__init__"
    Type "Any | None" cannot be assigned to type "BaseLanguageModel[Unknown]"
      Type "None" cannot be assigned to type "BaseLanguageModel[Unknown]" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py:216:35 - error: Argument of type "I18N | None" cannot be assigned to parameter "i18n" of type "I18N" in function "__init__"
    Type "I18N | None" cannot be assigned to type "I18N"
      Type "None" cannot be assigned to type "I18N" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py:218:35 - error: Argument of type "I18N | None" cannot be assigned to parameter "i18n" of type "I18N" in function "__init__"
    Type "I18N | None" cannot be assigned to type "I18N"
      Type "None" cannot be assigned to type "I18N" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py:220:35 - error: Cannot access member "partial" for type "str"
    Member "partial" is unknown (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py:226:25 - error: "bind" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py:226:46 - error: "slice" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py:232:31 - error: Argument of type "InstanceOf[ToolsHandler] | None" cannot be assigned to parameter "tools_handler" of type "ToolsHandler" in function "__init__"
    Type "InstanceOf[ToolsHandler] | None" cannot be assigned to type "ToolsHandler"
      Type "None" cannot be assigned to type "ToolsHandler" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py:233:23 - error: Argument of type "InstanceOf[CacheHandler] | None" cannot be assigned to parameter "cache" of type "CacheHandler" in function "__init__"
    Type "InstanceOf[CacheHandler] | None" cannot be assigned to type "CacheHandler"
      Type "None" cannot be assigned to type "CacheHandler" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agent.py:234:22 - error: Argument of type "I18N | None" cannot be assigned to parameter "i18n" of type "I18N" in function "__init__"
    Type "I18N | None" cannot be assigned to type "I18N"
      Type "None" cannot be assigned to type "I18N" (reportGeneralTypeIssues)
/Users/gvieira/Dev/crewai/crewAI/src/crewai/crew.py
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/crew.py:41:16 - error: Expression of type "(self: object) -> int" cannot be assigned to declared type "None"
    Type cannot be assigned to type "None" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/crew.py:72:6 - error: Argument of type "_V2Validator" cannot be assigned to parameter "__f" of type "(type[_T@classmethod], **_P@classmethod) -> _R_co@classmethod" in function "__init__"
    Type "_V2Validator" cannot be assigned to type "(type[_T@classmethod], **_P@classmethod) -> _R_co@classmethod"
      Type "_V2ValidatorClsMethod" cannot be assigned to type "(type[_T@classmethod], **_P@classmethod) -> _R_co@classmethod" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/crew.py:85:27 - error: Argument of type "AnyType@Json" cannot be assigned to parameter "s" of type "str | bytes | bytearray" in function "loads"
    Type "AnyType@Json" cannot be assigned to type "str | bytes | bytearray"
      "object*" is incompatible with "str"
      "object*" is incompatible with "bytes"
      "object*" is incompatible with "bytearray" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/crew.py:116:28 - error: "get" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/crew.py:116:61 - error: "get" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/crew.py:110:41 - error: Argument of type "InstanceOf[CacheHandler] | None" cannot be assigned to parameter "cache_handler" of type "CacheHandler" in function "set_cache_handler"
    Type "InstanceOf[CacheHandler] | None" cannot be assigned to type "CacheHandler"
      Type "None" cannot be assigned to type "CacheHandler" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/crew.py:121:52 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/crew.py:122:59 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/crew.py:139:26 - error: Function with declared return type "str" must return value on all code paths
    Type "None" cannot be assigned to type "str" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/crew.py:154:41 - error: "role" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/crew.py:159:16 - error: Expression of type "str | None" cannot be assigned to return type "str"
    Type "str | None" cannot be assigned to type "str"
      Type "None" cannot be assigned to type "str" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/crew.py:167:23 - error: "allow_delegation" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/crew.py:170:64 - error: "role" is not a known member of "None" (reportOptionalMemberAccess)
/Users/gvieira/Dev/crewai/crewAI/src/crewai/task.py
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/task.py:14:16 - error: Expression of type "(self: object) -> int" cannot be assigned to declared type "None"
    Type cannot be assigned to type "None" (reportGeneralTypeIssues)
/Users/gvieira/Dev/crewai/crewAI/src/crewai/agents/executor.py
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agents/executor.py:112:37 - error: Cannot access member "action" for type "AgentFinish"
    Member "action" is unknown (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agents/executor.py:112:37 - error: Cannot access member "action" for type "List[AgentAction]"
    Member "action" is unknown (reportGeneralTypeIssues)
/Users/gvieira/Dev/crewai/crewAI/src/crewai/agents/output_parser.py
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agents/output_parser.py:53:9 - warning: Expression value is unused (reportUnusedExpression)
/Users/gvieira/Dev/crewai/crewAI/src/crewai/agents/tools_handler.py
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agents/tools_handler.py:15:46 - error: Expression of type "None" cannot be assigned to parameter of type "CacheHandler"
    Type "None" cannot be assigned to type "CacheHandler" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agents/tools_handler.py:13:27 - error: Expression of type "None" cannot be assigned to declared type "CacheHandler"
    Type "None" cannot be assigned to type "CacheHandler" (reportGeneralTypeIssues)
/Users/gvieira/Dev/crewai/crewAI/src/crewai/agents/cache/cache_handler.py
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/agents/cache/cache_handler.py:9:13 - error: Expected type expression but received "(default: Any = PydanticUndefined, *, default_factory: (() -> Any) | None = None) -> Any" (reportGeneralTypeIssues)
/Users/gvieira/Dev/crewai/crewAI/src/crewai/tools/agent_tools.py
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/tools/agent_tools.py:23:39 - error: "tools" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/tools/agent_tools.py:30:39 - error: "tools" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/tools/agent_tools.py:49:30 - error: "errors" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/tools/agent_tools.py:52:30 - error: "errors" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/tools/agent_tools.py:61:30 - error: "errors" is not a known member of "None" (reportOptionalMemberAccess)
/Users/gvieira/Dev/crewai/crewAI/src/crewai/utilities/i18n.py
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/utilities/i18n.py:45:20 - error: Object of type "None" is not subscriptable (reportOptionalSubscript)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/utilities/i18n.py:45:45 - error: Cannot access member "get" for type "str"
    Member "get" is unknown (reportGeneralTypeIssues)
/Users/gvieira/Dev/crewai/crewAI/src/crewai/utilities/prompts.py
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/utilities/prompts.py:28:41 - error: List expression not allowed in type annotation
    Use List[T] to indicate a list type or Union[T1, T2] to indicate a union type (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/utilities/prompts.py:28:41 - error: Expected type expression but received "list[type[str]]" (reportGeneralTypeIssues)
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/utilities/prompts.py:32:16 - error: Expression of type "PromptTemplate" cannot be assigned to return type "str"
    "PromptTemplate" is incompatible with "str" (reportGeneralTypeIssues)
/Users/gvieira/Dev/crewai/crewAI/src/crewai/utilities/rpm_controller.py
  /Users/gvieira/Dev/crewai/crewAI/src/crewai/utilities/rpm_controller.py:44:27 - error: Cannot assign member "_timer" for type "RPMController"
    Type "None" cannot be assigned to type "Timer" (reportGeneralTypeIssues)
/Users/gvieira/Dev/crewai/crewAI/tests/agent_test.py
  /Users/gvieira/Dev/crewai/crewAI/tests/agent_test.py:68:43 - error: "memory" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/tests/agent_test.py:69:40 - error: "memory" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/tests/agent_test.py:128:32 - error: "last_used_tool" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/tests/agent_test.py:136:32 - error: "last_used_tool" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/tests/agent_test.py:219:74 - error: "_iter_next_step" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/tests/agent_test.py:245:72 - error: "_force_answer" is not a known member of "None" (reportOptionalMemberAccess)
/Users/gvieira/Dev/crewai/crewAI/tests/crew_test.py
  /Users/gvieira/Dev/crewai/crewAI/tests/crew_test.py:261:32 - error: "_cache" is not a known member of "None" (reportOptionalMemberAccess)
  /Users/gvieira/Dev/crewai/crewAI/tests/crew_test.py:263:32 - error: "_cache" is not a known member of "None" (reportOptionalMemberAccess)
/Users/gvieira/Dev/crewai/crewAI/tests/task_test.py
  /Users/gvieira/Dev/crewai/crewAI/tests/task_test.py:54:9 - error: No parameter named "allow_delegation" (reportGeneralTypeIssues)
55 errors, 1 warning, 0 informations 
New logs
0 errors, 0 warnings, 0 informations

@gvieira gvieira self-assigned this Jan 27, 2024
joaomdmoura
joaomdmoura previously approved these changes Jan 27, 2024
executor_args[
"request_within_rpm_limit"
] = self._rpm_controller.check_or_wait
executor_args["request_within_rpm_limit"] = (
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been fighting with this for a long time. Github's black says this is the correct form, while VSCode insist on the the former way.

@gvieira gvieira changed the title Gui/fix typing errors Fix static typing errors Jan 27, 2024
@joaomdmoura
Copy link
Collaborator

something wrong with the specs, running here in github, but this one should be good to go

@gvieira
Copy link
Collaborator Author

gvieira commented Jan 27, 2024

something wrong with the specs, running here in github, but this one should be good to go

I want to fix tests before merging. All good! :)

@gvieira
Copy link
Collaborator Author

gvieira commented Jan 29, 2024

@joaomdmoura the issue with tests was the incompatible langchain version. While we are running 0.1.0, the build was using 0.1.4, which breaks everything. I've fixed the version for now.

@joaomdmoura
Copy link
Collaborator

Oh boy we might need to update it then, merging this one 😎👉👉

@gvieira
Copy link
Collaborator Author

gvieira commented Jan 29, 2024

@joaomdmoura we are ready to merge this. Don't wanna break your build, so do it when you feel like it. :)

@joaomdmoura joaomdmoura merged commit 29c31a2 into main Jan 29, 2024
3 checks passed
@joaomdmoura joaomdmoura deleted the gui/fix-typing-errors branch January 29, 2024 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants