You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/02/21 12:47:35 UTC

[GitHub] [airflow] kaxil commented on a change in pull request #7483: [AIRFLOW-XXXX] Document new session handling guidelines

kaxil commented on a change in pull request #7483: [AIRFLOW-XXXX] Document new session handling guidelines
URL: https://github.com/apache/airflow/pull/7483#discussion_r382563069
 
 

 ##########
 File path: CONTRIBUTING.rst
 ##########
 @@ -321,6 +326,47 @@ Your code must pass all the static code checks in Travis CI in order to be eligi
 The easiest way to make sure your code is good before pushing is to use pre-commit checks locally
 as described in the static code checks documentation.
 
+.. _coding_style:
+
+Coding style and best practices
+===============================
+
+Most of your coding style rules are enforced programmatically by flake8 and pylint (which are run automatically
+on every pull request), but there are some rules that are not yet automated and are more Airflow specific or
+semantic than style
+
+Database Session Handling
+-------------------------
+
+**Explicit is better than implicit.** If a function accepts a ``session`` parameter it should not commit the
+transaction itself. Session management is up to the caller.
+
+To make this easier there is the ``create_session`` helper:
+
+.. code-block:: python
+
+    from airflow.utils.db import create_session
 
 Review comment:
   ```suggestion
       from airflow.utils.session import create_session
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services