Argument name should be lowercase

dn PythonList at DancesWithMice.info
Fri Nov 11 03:54:26 EST 2022


PyCharm is warning against using an identifier of all upper-case letters 
as a function's parameter, saying "Argument name should be lowercase". 
(weak, code smell)


The application consists of three+ files:
- configuration
- mainline script
- module of workbook functions

The mainline reads the configuration parameters to set the application's 
environment. All of the config/settings are constants. Some of them 
appear as a dictionary (PRICES_WORKBOOK) defining a workbook's 
(spreadsheet's) parameters, eg the filename, which work-sheet to use, etc.


The mainline calls the relevant functions from within the module, 
as-needed:-

import prices_workbook as pw
...
product_prices = pw.build_product_prices_dictionary( PRICES_WORKBOOK )


The module's function definition is:

def build_product_prices_dictionary( WORKBOOK_DEFINITIONS:dict )->dict:
...
     price_array = xl.iget_array(
         file_name=WORKBOOK_DEFINITIONS[ "file_name" ],
         ...

(the function def is flagged, as above)


A quick scan of PEP-008 failed to yield anything relevant. Why is this 
frowned upon as poor Python, or a matter of style?

Yes, a dict is mutable, but the upper-case denoting a constant indicates 
that none of its values are to be changed by the programmer.

As far as the function is concerned, the dict and its contents are 
constants.
(but the dict can't be treated as a global ENV[IRONMENT] object, because 
it has to cross into the module's namespace)


Is passing the dict as an argument/parameter considered to be 
incompatible with its designation as a constant?

Perhaps the style should be more enum-like, ie the dict's name in 
lower-case, with the key-named in upper case, eg

     workbook_definitions[ "FILE_NAME" ]


Am not particularly concerned by the IDE raising this as a 'problem' - 
will quite happily ignore and carry-on; but am curious as to the logic 
behind the analysis - and why it doesn't come readily to mind.

Advice, comments, critique welcome!

-- 
Regards,
=dn


More information about the Python-list mailing list