evennia/CODING_STYLE

53 lines
No EOL
1.9 KiB
Text

Evennia Code Style
------------------
All code submitted or committed to the Evennia project needs to follow the
guidelines outlined in Python PEP 8, which may be found at:
http://www.python.org/dev/peps/pep-0008/
A quick list of code style points
---------------------------------
* 4-space indendation, NO TABS!
* Unix line endings.
* CamelCase is only used for classes, nothing else.
* All non-global variable names and all function names are to be lowercase,
words separated by underscores. Variable names should always be more than
two letters long.
* Module-level global variables (only) are to be in CAPITAL letters.
* Imports are to be done in this order:
- Python modules (builtins and modules otherwise unrelated to Evennia)
- Twisted
- Django
- Evennia src/ modules
- Evennia game/ modules
Pylint
------
The program 'pylint' (http://www.logilab.org/857) is a useful tool for checking
your Python code for errors. It will also check how well your code adheres to
the PEP 8 guidelines and tells you what can be improved.
Since pylint cannot catch dynamically created variables used in commands and
elsewhere in Evennia, one needs to reduce some checks to avoid false errors and
warnings. For best results, run pylint like this:
> pylint --disable=E1101,E0102,F0401,W0232,R0903 filename.py
To avoid entering the options every time, you can auto-create a pylintrc file by
using the option --generate-rcfile. You need to dump this output into a
file .pylintrc, for example like this (linux):
> pylint --disable=E1101,E0102,F0401,W0232,R0903 --generate-rcfile >& ~/.pylintrc
From now on you can then just run
> pylint filename.py
Ask Questions!
--------------
If any of the rules outlined in PEP 8 or in the list above doesn't make sense, please
don't hesitate to ask on the Evennia mailing list at http://evennia.com.
Keeping our code style uniform makes this project much easier for a wider group
of people to participate in.