Pycharm expected type 'optional[bytes]' got 'str' instead

It seems like rootPath is being treated as a bytes object (a small bug maybe?) or the warning is for another part.

In general, what PyCharm and the error is essentially warning you about is that the parameter has to either be None or bytes. That's what Optional means, Optional[type] is either None or type which in your case is bytes.

In a simple Python REPL the message is slightly different but the gist is the same:

b'hello/world'.rsplit('/') # error bytes-like object required

Instead you need to supply a byte separator:

b'hello/world'.rsplit(b'/') 

or None in order to get it to work.

Either there's a small bug in PyCharm and it's reporting rsplit incorrectly here or the warning is for another part of your code.