I need to send a byte string command over serial port, and read this command from a dictionary. Pylance throws an error, though everything is working fine. Writing the byte string command directly to serial port, there is no error. # No error writing byte string as an argument ----------------------- cmd_direct = b'AT\r' comport.write(cmd_direct) # Error reading byte string from dictionary first ----------------------- cmd_dict = { "cmd1": b'AT\r', "cmd2": b'AT+HTTPINIT\r' } cmd_value_dict = cmd_dict.get("cmd1") comport.write(cmd_value_dict) # ^^^^^^^^^^ # Argument of type "bytes | None" cannot be assigned to parameter "b" of type "ReadableBuffer" in function "write" # Type "bytes | None" is not assignable to type "ReadableBuffer" # "None" is incompatible with protocol "Buffer" # "__buffer__" is not present Pylancer(eportArgumentType) # (variable) cmd_value_dict: bytes | None The debugger in both cases shows exactly the same value when sending, so why is this error? I'm just a beginner on python and I don't understand the error message. Maybe someone can explain, what it means and how to avoid (though it's actually working). Continue reading...