home / github / issues

Menu
  • GraphQL API
  • Search all tables

issues: 606549469

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
606549469 MDU6SXNzdWU2MDY1NDk0Njk= 4002 Remove dangerous default argument 40136154 closed 0     16 2020-04-24T19:58:59Z 2020-05-23T17:30:51Z 2020-05-23T17:30:51Z CONTRIBUTOR      

Hi, It is good not to use the default arguments while calling a function.

MCVE Code Sample

In file xarray/tests/test_conventions.py ```python

Your code here

329 @contextlib.contextmanager 330 def roundtrip( 331 self, data, save_kwargs={}, open_kwargs={}, allow_cleanup_failure=False332 ): 333 store = CFEncodedInMemoryStore() 334 data.dump_to_store(store, **save_kwargs) ```

Problem Description

Default arguments in Python are evaluated once when the function definition is executed. This means that the expression is evaluated only once when the function is defined and that the same value is used for each subsequent call. So if you are modifying the mutable default argument — a list, dict, etc., it will be modified for all future calls.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4002/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 0 rows from issues_id in issues_labels
  • 16 rows from issue in issue_comments
Powered by Datasette · Queries took 0.653ms · About: xarray-datasette