Von: Bináris <wikiposta@gmail.com>
Gesendet: 29.11.2022 17:32
An: Pywikibot discussion list <pywikibot@lists.wikimedia.org>
Betreff: [pywikibot] Re: pywikibot is making a mockery of my tests
Roy Smith <roy@panix.com> ezt írta (időpont: 2022. nov. 29., K, 17:26):
Ah, I've got this.  The problem is that pywikibot.Site isn't a class, it's a factory function that returns cached instances of APISite.
Should it not have a lower case name in this case?

Yes - due to PEP8 naming convention
No - it i aiming a Site class but the right class is filled during instantiation. There is some magic to get the site class from config.py
No - it exists for 15 years https://static-codereview.wikimedia.org/pywikipedia/5088.html
No - the previous function was getSite() which was used with compat 5 years earlier
No - it would confict with site module which unfortunately conficts with Python's site namespace in Sphinx
No - it is well documented: https://doc.wikimedia.org/pywikibot/stable/api_ref/pywikibot.html#pywikibot.Site
No - it is used 101 times in framework code https://codesearch.wmcloud.org/pywikibot/?q=Site%5C(&i=nope&files=&excludeFiles=&repos=
No - it is not uncommon to have CamelCase for factory functions e.g. Django Coding style says "Use InitialCaps for class names (or for factory functions that return classes)"
No - I like that previous rule ;-)

Sorry, yes is in minority :-D