Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Split contributing and add Python style overview
Patryk Zawadzki5ebcb980b8a0
diff --git a/.editorconfig b/.editorconfigindex d9c59149b9..9009232132 100644--- a/.editorconfig+++ b/.editorconfig@@ -1,15 +1,16 @@root = true[*]+charset = utf-8end_of_line = lf-insert_final_newline = trueindent_style = space+insert_final_newline = truetrim_trailing_whitespace = true-charset = utf-8[*.py]indent_size = 4max_line_length = 79+multi_line_output = 4quote_type = single[*.js]diff --git a/docs/contributing.rst b/docs/contributing.rstindex 44e3e42818..da790f7e32 100644--- a/docs/contributing.rst+++ b/docs/contributing.rst@@ -4,7 +4,9 @@ Contributing GuidesPlease use GitHub issues and pull requests to report problems and discuss new features.-Naming Conventions-------------------+.. toctree::+ :maxdepth: 1-To keep a consistent code structure we follow some rules of naming files. Templates use underscore as a word separator and static files, as they end up as a part of URL, use dashes.+ contributing/editorconfig+ contributing/coding-style+ contributing/namingdiff --git a/docs/contributing/coding-style.rst b/docs/contributing/coding-style.rstnew file mode 100644index 0000000000..170e5b1b20--- /dev/null+++ b/docs/contributing/coding-style.rst@@ -0,0 +1,57 @@+Coding Style+============+++Python+------++Always follow `PEP 8 <https://www.python.org/dev/peps/pep-0008/>`_ but keep in mind that consistency is important.++String Literals+~~~~~~~~~~~~~~~++Prefer single quotes to double quotes unless the string itself contains single quotes that would need to be needlessly escaped.++Wrapping Code+~~~~~~~~~~~~~++When wrapping code follow the "hanging grid" format:++.. code-block:: python++ some_dict = {+ 'one': 1,+ 'two': 2,+ 'three': 3}++.. code-block:: python++ some_list = [+ 'foo', 'bar', 'baz']++Python is an indent-based language and we believe that beautiful, readable code is more important than saving a single line of ``git diff``. Please avoid dangling parentheses, brackets, square brackets or hanging commas even if the Django project seems to encourage this programming style:++.. code-block:: python++ this_is_wrong = {+ 'one': 1,+ 'two': 2,+ 'three': 3,+ }++Please break multi-line code immediately after the parenthesis and avoid relying on a precise number of spaces for alignment:++.. code-block:: python++ also_wrong('this is hard',+ 'to maintain',+ 'as it often needs to be realigned')++Linters+~~~~~~~++Use `pylint <https://www.pylint.org/>`_ with the ``pylint-django`` plugin to catch errors in your code.++Use `pycodestyle <http://pycodestyle.pycqa.org/en/latest/>`_ to make sure your code adheres to PEP 8.++Use `pydocstyle <http://pydocstyle.pycqa.org/en/latest/>`_ to check that your docstrings are properly formatted.diff --git a/docs/contributing/editorconfig.rst b/docs/contributing/editorconfig.rstnew file mode 100644index 0000000000..5e7c556f68--- /dev/null+++ b/docs/contributing/editorconfig.rst@@ -0,0 +1,6 @@+EditorConfig+============++The root of the repository contains an `EditorConfig <http://editorconfig.org/>`_ file.++Most editors and IDEs support this file either directly or via plugins. If you make sure that your programming environment respects the contents of this file you will automatically get correct indentation, encoding, and line endings.diff --git a/docs/contributing/naming.rst b/docs/contributing/naming.rstnew file mode 100644index 0000000000..e377c15067--- /dev/null+++ b/docs/contributing/naming.rst@@ -0,0 +1,22 @@+Naming Conventions+==================++To keep a consistent code structure we follow some rules when naming files.+++Python Modules+--------------++Try to have the name reflect the function of the file. If possible avoid generic file names such as ``utils.py``.+++Django Templates+----------------++Use underscore as a word separator.+++Static Files+------------++Use dashes to separate words as they end up as part of the URL.