Replit Type Checker is Wrong Most of the Time

Problem description

A problem I often encounter with the Replit type checker (pyright-extended, I think) is that it seems to make many assumptions that other type checkers don’t make. For example, when I was using ChatGroq with Langchain the other day, I passed in my API key as such:

llm = ChatGroq(

And then pyright-extended tells me this:

Argument of type "str" cannot be assigned to parameter "api_key" of type "SecretStr | None" in function "__init__"
  Type "str" cannot be assigned to type "SecretStr | None"
    "str" is incompatible with "SecretStr"
    "str" is incompatible with "None"

If you go to the documentation for SecretStr, it is syntactic sugar designed to make it clear when you are dealing with a sensitive string, and the point of it is that you pass a string and it is converted to a SecretStr. This forces me to add #type:ignore to the end of the line, which is almost always bad practice, or to come up with a way to convert a str to a SecretStr, or make an assert statement, when the whole point is that it happens automatically.

I really benefit from type checking, but Replit type checking is causing problems by making me write a bunch of assert statements, #type:ignore comments, and other things that add complexity to an otherwise simple task.


Expected behavior

Replit type checking should understand duck typing, and not show syntax errors in the editor when a class that is functionally equivalent to another class is used.

Actual behavior

Replit type checking relies very heavily on the type definition of a function, which is a problem in Python.

Steps to reproduce

  • Make a new Repl
  • Install langchain and langchain_groq
  • Type this code:
import os

from langchain_groq import ChatGroq
llm = ChatGroq(




Windows 11

Device if mobile



Core membership

Please upload screenshots

1 Like

Hi @CallumCM !
Does the repl run fine, even with this error?


This is a warning from the repl’s code intelligence support (not an error). In this case, ChatGroq is expecting an instance of SecretStr, which is a type of object which prevents its data from showing up in logs, rather than a regular string. You can safely ignore this, but just know that the module recommends that you use SecretStr for security purposes.

1 Like

That’s absolutely correct, the issue is that I don’t want it to tell me to use SecretStr, since Pydantic is supposed to convert str to SecretStr under the hood (the documentation for LangChain writes it using a string, and you are not supposed to create SecretStr objects directly, they are automatically generated when you specify SecretStr-type proeprties in Pydantic models).

It’s not a huge issue since it is in fact just a warning, and does not stop me from developing. The reason I am reporting it as a bug is because it is encouraging worse practices (converting the str to a SecretStr manually), and it generally annoying since it makes finding real errors more difficult.

Thank you!

1 Like

Try appending # type: ignore to the end of that line to suppress errors there.


They do that, but they don’t want to, since they shouldn’t have to


@CallumCM You should unmark that as solution, since the issue hasn’t been fixed


Thanks for taking the time to share such a nice and detailed bug write-up @CallumCM. I’ll get this reported to our team for potential future improvements.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.