Re: Expected type 'optional[bytes]' got 'str' instead

2016-09-16 Thread Peter Otten
= os.path.abspath(__file__) >>> >>> rootPath = (rootPath.rsplit('\\', 1)[0]).rsplit('\\', 1)[0] >>> >>> >>> PyCharm inspection gave me warning on argument '\\' of the 2nd rsplit, >>> >>> Expected type 'optional[bytes]' got 'str' in

Re: Expected type 'optional[bytes]' got 'str' instead

2016-09-13 Thread Peter Otten
Daiyue Weng wrote: > Hi, I have the following piece of code, > > rootPath = os.path.abspath(__file__) > > rootPath = (rootPath.rsplit('\\', 1)[0]).rsplit('\\', 1)[0] > > > PyCharm inspection gave me warning on argument '\\' of the 2nd rsplit, > > Expected t

Re: Expected type 'optional[bytes]' got 'str' instead

2016-09-13 Thread Chris Angelico
On Tue, Sep 13, 2016 at 9:19 PM, Daiyue Weng wrote: > Could you give me an example of doing this using os.path.split and > os.path.join? > > thanks Sure, but I'm keeping this on list. os.path.split basically does the same thing you do. # maintaining your non-PEP-8 names

Re: Expected type 'optional[bytes]' got 'str' instead

2016-09-13 Thread Chris Angelico
rgument '\\' of the 2nd rsplit, > > Expected type 'optional[bytes]' got 'str' instead > Well, the first thing I'd do is use os.path.split instead of rsplit :) Or alternatively, os.path.join using dot-dot. And if that's not sufficient, I'd reach for pathlib. Whichever way I do it, I wo

Expected type 'optional[bytes]' got 'str' instead

2016-09-13 Thread Daiyue Weng
Hi, I have the following piece of code, rootPath = os.path.abspath(__file__) rootPath = (rootPath.rsplit('\\', 1)[0]).rsplit('\\', 1)[0] PyCharm inspection gave me warning on argument '\\' of the 2nd rsplit, Expected type 'optional[bytes]' got 'str' instead If I changed it to, rootPath