You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/10/20 10:26:36 UTC

[GitHub] [spark] Fokko commented on pull request #29122: [SPARK-32320][PYSPARK] Remove mutable default arguments

Fokko commented on pull request #29122:
URL: https://github.com/apache/spark/pull/29122#issuecomment-712753625


   Fixed the voilations:
   ```
   ./python/pyspark/ml/regression.py:1743:40: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
                    quantileProbabilities=list([0.01, 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99]),
                                          ^
   ./python/pyspark/ml/regression.py:1761:41: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
                     quantileProbabilities=list([0.01, 0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99]),
                                           ^
   ./python/pyspark/ml/tuning.py:511:46: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
       def __init__(self, bestModel, avgMetrics=[], subModels=None):
                                                ^
   ./python/pyspark/ml/tuning.py:871:53: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
       def __init__(self, bestModel, validationMetrics=[], subModels=None):
                                                       ^
   ./python/pyspark/resource/profile.py:35:63: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
       def __init__(self, _java_resource_profile=None, _exec_req={}, _task_req={}):
                                                                 ^
   ./python/pyspark/resource/profile.py:35:77: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
       def __init__(self, _java_resource_profile=None, _exec_req={}, _task_req={}):
                                                                               ^
   ./python/pyspark/sql/functions.py:2479:36: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
   def from_json(col, schema, options={}):
                                      ^
   ./python/pyspark/sql/functions.py:2527:26: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
   def to_json(col, options={}):
                            ^
   ./python/pyspark/sql/functions.py:2567:34: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
   def schema_of_json(json, options={}):
                                    ^
   ./python/pyspark/sql/functions.py:2597:32: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
   def schema_of_csv(csv, options={}):
                                  ^
   ./python/pyspark/sql/functions.py:2623:25: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
   def to_csv(col, options={}):
                           ^
   ./python/pyspark/sql/functions.py:2934:35: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
   def from_csv(col, schema, options={}):
                                     ^
   ./python/pyspark/sql/avro/functions.py:29:47: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
   def from_avro(data, jsonFormatSchema, options={}):
                                                 ^
   ./dev/sparktestsupport/modules.py:34:97: B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
       def __init__(self, name, dependencies, source_file_regexes, build_profile_flags=(), environ={},
                                                                                                   ^
   14    B006 Do not use mutable data structures for argument defaults.  They are created during function definition time. All calls to the function reuse this one instance of that data structure, persisting changes between them.
   14
   1
   ```
   
   Furthermore:
   - Added `flake8-bugbear` to the CI. This is a well known additional set of rules next to flake8: https://github.com/pycqa/flake8-bugbear
   - Added the `B006` rule, which is the mutable arguments rule :)


----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org