I guess, the manual https://www.mediawiki.org/wiki/Manual:Pywikibot/MySQL#Pywikibot and comments in user-config.py should have description like:
db_username, db_password - the credentials to connect to the database, using if set db_connect_file = None
On this manual link already written. that if this variable db_connect_file is not defined or = '', then pwb by default use credentials from the .my.cnf file.
This is so. You can check in debugger, that None is necessary for using db_username/db_password. See the screenshot of PyCharm debuger:
But my edit was declined. With comment that it can also be empty or not set at all, any case user/password will be use if specified. See also discussion. Perhaps misunderstanding here.