internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: django-import-export/django-import-export

Issue:
(xls/xlsx) Time fields rejected on import even though they are valid
**Describe the bug**
When importing xls or xlsx files, receive "Enter a valid time" errors for seemingly valid time fields.
This seems to happen because tablib is already converting these into datetime.time fields, then the TimeWidget.clean() method attempts to convert this time field again.

**To Reproduce**
Import an xlsx file with a true Time field in "h:mm:ss" format and use the matching format for the widget.

**Versions (please complete the following information):**
 - Django Import Export: 2.5.0
 - Python: 3.6.8
 - Django: 3.2.5

**Expected behavior**
Import properly when it is actually a time field, reject if there is a value python can't figure out.

**Screenshots**

**Additional context**



Discussion:

Resolving patch:
diff --git a/import_export/widgets.py b/import_export/widgets.py
--- a/import_export/widgets.py
+++ b/import_export/widgets.py
@@ -1,5 +1,5 @@
 import json
-from datetime import date, datetime
+from datetime import date, datetime, time
 from decimal import Decimal
 
 import django
@@ -257,6 +257,8 @@ def __init__(self, format=None):
     def clean(self, value, row=None, *args, **kwargs):
         if not value:
             return None
+        if isinstance(value, time):
+            return value
         for format in self.formats:
             try:
                 return datetime.strptime(value, format).time()


Test patch:
diff --git a/tests/core/tests/test_widgets.py b/tests/core/tests/test_widgets.py
--- a/tests/core/tests/test_widgets.py
+++ b/tests/core/tests/test_widgets.py
@@ -172,6 +172,8 @@ def test_clean_raises_ValueError(self):
         with self.assertRaisesRegex(ValueError, "Enter a valid time."):
             self.widget.clean("20:15:00")
 
+    def test_clean_returns_time_when_time_passed(self):
+        self.assertEqual(self.time, self.widget.clean(self.time))
 
 class DurationWidgetTest(TestCase):
Repository: django-import-export/django-import-export

Issue:
``self.list_select_related`` could use``self.get_list_select_related`` in admin.ExportMixin
Hey, 

``self.list_select_related`` could be``self.get_list_select_related(request)`` in admin.ExportMixin:

https://github.com/django-import-export/django-import-export/blob/main/import_export/admin.py#L371

That line. 

Django has a function for it now:

https://github.com/django/django/blob/main/django/contrib/admin/options.py#L1090

Perhaps it would be useful to use it, to play even more nicely withe rest of the ecosystem. 

I think I'm going to provide a PR for this some time later. 


Discussion:
Thanks for raising - PR is welcome - check out the [contributing guidelines](https://github.com/django-import-export/django-import-export/blob/main/CONTRIBUTING.md)

Resolving patch:
diff --git a/import_export/admin.py b/import_export/admin.py
--- a/import_export/admin.py
+++ b/import_export/admin.py
@@ -608,6 +608,7 @@ def get_export_queryset(self, request):
         """
         list_display = self.get_list_display(request)
         list_display_links = self.get_list_display_links(request, list_display)
+        list_select_related = self.get_list_select_related(request)
         list_filter = self.get_list_filter(request)
         search_fields = self.get_search_fields(request)
         if self.get_actions(request):
@@ -622,7 +623,7 @@ def get_export_queryset(self, request):
             'list_filter': list_filter,
             'date_hierarchy': self.date_hierarchy,
             'search_fields': search_fields,
-            'list_select_related': self.list_select_related,
+            'list_select_related': list_select_related,
             'list_per_page': self.list_per_page,
             'list_max_show_all': self.list_max_show_all,
             'list_editable': self.list_editable,


Test patch:
Repository: django-import-export/django-import-export

Issue:
`RowResult.new_record` is redundant and could be deprecated
**Describe the bug**

The import process sets a flag on [`RowResult`](https://github.com/django-import-export/django-import-export/blob/a5dda8a511f42917c3daf97ac787964ea91ab8af/import_export/resources.py#L765) which is the boolean value indicating if the import is `new`.
However the `RowResult` already stores `import_type = IMPORT_TYPE_NEW`, hence this seems redundant and could be deprecated.

`new_record` is not documented and doesn't appear anywhere else in the code base.

**Versions (please complete the following information):**
 - Django Import Export: 3.2.0
 - Python 3.10
 - Django 4.1.8





Discussion:
Deprecation comment added in #1584 
Since some implementations out there might be using this, I propose to remove in v4

Resolving patch:
diff --git a/import_export/resources.py b/import_export/resources.py
--- a/import_export/resources.py
+++ b/import_export/resources.py
@@ -768,7 +768,6 @@ def import_row(
                 row_result.import_type = RowResult.IMPORT_TYPE_NEW
             else:
                 row_result.import_type = RowResult.IMPORT_TYPE_UPDATE
-            row_result.new_record = new
             if not skip_diff:
                 original = deepcopy(instance)
                 diff = self.get_diff_class()(self, original, new)
diff --git a/import_export/results.py b/import_export/results.py
--- a/import_export/results.py
+++ b/import_export/results.py
@@ -62,11 +62,6 @@ def __init__(self):
         #: This value is only set for updates.
         self.original = None
 
-        #: A boolean flag indicating whether the record is `new` or not.
-        #: Deprecated: use the value of ``import_type`` instead.
-        #: See issue 1586.
-        self.new_record = None
-
     def add_instance_info(self, instance):
         if instance is not None:
             # Add object info to RowResult (e.g. for LogEntry)


Test patch:
Repository: django-import-export/django-import-export

Issue:
Possibility of race condition during import
**Describe the bug**

For any model which permits concurrent writes, the import process is vulnerable to a race condition.

- The [check](https://github.com/django-import-export/django-import-export/blob/eb27821a899a651fd11fe92a5b88955eed35ae0c/import_export/resources.py#L661) for new or existing objects identifies that our row is 'new'
- From another process, an object with the same unique id as the row is inserted before the call to [`save()`](https://github.com/django-import-export/django-import-export/blob/eb27821a899a651fd11fe92a5b88955eed35ae0c/import_export/resources.py#L469)
- If there is a unique db constraint on the field, then the call to save will fail, otherwise a duplicate row will be inserted.

**To Reproduce**

- Can be reproduced by inserting an object between `get_or_init_instance()` and `save()` - e.g. one could add a long sleep call in `before_save_instance()`, or simply create the object in `before_save_instance()`.

**Versions (please complete the following information):**
 - Django Import Export: 2.8.1
 - Python 3.10
 - Django 4.0.5

**Expected behavior**

it would be ideal if the process was protected from this occurrence, such that you can assume that your object will be created safely.

**Additional context**

I have actually seen this issue in production.  The workaround was to override `save_instance()` and add a call to `create_or_update()`, which is ok for my use case, but might not be for others, because the race condition still exists in terms of what gets updated.  i.e. you could overwrite the other processes insert with an update.

Another idea might be to lock the table, but this could have negative performance implications.  Maybe this should be documented and left as an option for users if it is important.



Discussion:

Resolving patch:
diff --git a/import_export/resources.py b/import_export/resources.py
--- a/import_export/resources.py
+++ b/import_export/resources.py
@@ -553,9 +553,19 @@ def save_instance(self, instance, is_create, row, **kwargs):
                 # we don't have transactions and we want to do a dry_run
                 pass
             else:
-                instance.save()
+                self.do_instance_save(instance)
         self.after_save_instance(instance, row, **kwargs)
 
+    def do_instance_save(self, instance):
+        """
+        A method specifically to provide a single overridable hook for the instance
+        save operation.
+        For example, this can be overridden to implement update_or_create().
+
+        :param instance: The model instance to be saved.
+        """
+        instance.save()
+
     def before_save_instance(self, instance, row, **kwargs):
         r"""
         Override to add additional logic. Does nothing by default.


Test patch:
Repository: django-import-export/django-import-export

Issue:
tests breaking due to `log_action` deprecation in django5
**Describe the bug**

```
django.utils.deprecation.RemovedInDjango60Warning: LogEntryManager.log_action() is deprecated. Use log_actions() instead.
```

**To Reproduce**

```
tox -r -e py311-djangomain 
```

**Versions (please complete the following information):**
 - Django Import Export: 3.3.1
 - Python 3.11
 - Django main

**Expected behavior**

Tests should pass

**Additional context**

[link](https://github.com/django/django/blob/36173cf29d6ad0b0f0cd24326834dddfff2db7f3/docs/internals/deprecation.txt#L59)



Discussion:

Resolving patch:
diff --git a/import_export/admin.py b/import_export/admin.py
--- a/import_export/admin.py
+++ b/import_export/admin.py
@@ -230,14 +230,20 @@ def generate_log_entries(self, result, request):
                     row.import_type != row.IMPORT_TYPE_ERROR
                     and row.import_type != row.IMPORT_TYPE_SKIP
                 ):
-                    LogEntry.objects.log_action(
-                        user_id=request.user.pk,
-                        content_type_id=content_type_id,
-                        object_id=row.object_id,
-                        object_repr=row.object_repr,
-                        action_flag=logentry_map[row.import_type],
-                        change_message=_("%s through import_export" % row.import_type),
-                    )
+                    with warnings.catch_warnings():
+                        warnings.filterwarnings(
+                            "ignore", category=PendingDeprecationWarning
+                        )
+                        LogEntry.objects.log_action(
+                            user_id=request.user.pk,
+                            content_type_id=content_type_id,
+                            object_id=row.object_id,
+                            object_repr=row.object_repr,
+                            action_flag=logentry_map[row.import_type],
+                            change_message=_(
+                                "%s through import_export" % row.import_type
+                            ),
+                        )
 
     def add_success_message(self, result, request):
         opts = self.model._meta


Test patch:
Repository: django-import-export/django-import-export

Issue:
Export confirm page does not show the list of fields to be exported
**Describe the bug**

Import workflow shows the list of fields that will be imported for each resource:

![image](https://github.com/django-import-export/django-import-export/assets/6249838/2b1625df-8639-456b-acd3-8a2debfff1ca)

However the export workflow does not show this:

![image](https://github.com/django-import-export/django-import-export/assets/6249838/f957ea01-fdb1-44ec-8c3c-860a3051828b)


**To Reproduce**

Click on 'Export' button for the Book model.


**Versions (please complete the following information):**
 - Django Import Export: 3.3.3
 - Python 3.11
 - Django 4.2

**Expected behavior**

A list of fields should be presented to the user for each resource on export.




Discussion:

Resolving patch:
diff --git a/import_export/admin.py b/import_export/admin.py
--- a/import_export/admin.py
+++ b/import_export/admin.py
@@ -833,6 +833,16 @@ def export_action(self, request, *args, **kwargs):
         context["title"] = _("Export")
         context["form"] = form
         context["opts"] = self.model._meta
+        context["fields_list"] = [
+            (
+                res.get_display_name(),
+                [
+                    field.column_name
+                    for field in res(model=self.model).get_user_visible_fields()
+                ],
+            )
+            for res in self.get_export_resource_classes()
+        ]
         request.current_app = self.admin_site.name
         return TemplateResponse(request, [self.export_template_name], context)
 


Test patch:
diff --git a/tests/core/tests/test_admin_integration.py b/tests/core/tests/test_admin_integration.py
--- a/tests/core/tests/test_admin_integration.py
+++ b/tests/core/tests/test_admin_integration.py
@@ -647,6 +647,31 @@ def test_import_admin_uses_import_format_settings(self):
 
 
 class ExportAdminIntegrationTest(AdminTestMixin, TestCase):
+    def test_export_displays_resources_fields(self):
+        response = self.client.get("/admin/core/book/export/")
+        self.assertEqual(response.status_code, 200)
+        self.assertEqual(
+            response.context["fields_list"],
+            [
+                (
+                    "BookResource",
+                    [
+                        "id",
+                        "name",
+                        "author",
+                        "author_email",
+                        "imported",
+                        "published",
+                        "published_time",
+                        "price",
+                        "added",
+                        "categories",
+                    ],
+                ),
+                ("Export/Import only book names", ["id", "name"]),
+            ],
+        )
+
     def test_export(self):
         response = self.client.get("/admin/core/book/export/")
         self.assertEqual(response.status_code, 200)
Repository: django-import-export/django-import-export

Issue:
`SimpleArrayWidget.render()` crashes if value is None
**Describe the bug**

`SimpleArrayWidget.render()` crashes if value is None

```
'NoneType' object is not iterable
```




Discussion:

Resolving patch:
diff --git a/import_export/widgets.py b/import_export/widgets.py
--- a/import_export/widgets.py
+++ b/import_export/widgets.py
@@ -402,8 +402,12 @@ def render(self, value, obj=None):
         """
         :return: A string with values separated by ``separator``.
           If ``coerce_to_string`` is ``False``, the native array will be returned.
+          If ``value`` is None, None will be returned if ``coerce_to_string``
+            is ``False``, otherwise an empty string will be returned.
         """
         self._obj_deprecation_warning(obj)
+        if value is None:
+            return "" if self.coerce_to_string is True else None
         if not self.coerce_to_string:
             return value
         return self.separator.join(str(v) for v in value)


Test patch:
diff --git a/tests/core/tests/test_widgets.py b/tests/core/tests/test_widgets.py
--- a/tests/core/tests/test_widgets.py
+++ b/tests/core/tests/test_widgets.py
@@ -757,3 +757,13 @@ def test_render_no_coerce_to_string(self):
         v = [1, 2, 3]
         self.widget = widgets.SimpleArrayWidget(coerce_to_string=False)
         self.assertEqual(v, self.widget.render(v))
+
+    def test_render_none_coerce_to_string_is_True(self):
+        self.widget = widgets.SimpleArrayWidget()
+        self.assertTrue(self.widget.coerce_to_string)
+        self.assertEqual("", self.widget.render(None))
+
+    def test_render_none_coerce_to_string_is_False(self):
+        self.widget = widgets.SimpleArrayWidget(coerce_to_string=False)
+        self.assertFalse(self.widget.coerce_to_string)
+        self.assertIsNone(self.widget.render(None))
Repository: django-import-export/django-import-export

Issue:
`is_create` param should be passed into new `do_instance_save()` method
**Describe the bug**

`is_create` param should be passed into new `do_instance_save()` method



Discussion:

Resolving patch:
diff --git a/import_export/resources.py b/import_export/resources.py
--- a/import_export/resources.py
+++ b/import_export/resources.py
@@ -305,16 +305,18 @@ def save_instance(self, instance, is_create, row, **kwargs):
                 # we don't have transactions and we want to do a dry_run
                 pass
             else:
-                self.do_instance_save(instance)
+                self.do_instance_save(instance, is_create)
         self.after_save_instance(instance, row, **kwargs)
 
-    def do_instance_save(self, instance):
+    def do_instance_save(self, instance, is_create):
         """
         A method specifically to provide a single overridable hook for the instance
         save operation.
         For example, this can be overridden to implement update_or_create().
 
         :param instance: The model instance to be saved.
+        :param is_create: A boolean flag to indicate whether this is a new object
+                          to be created, or an existing object to be updated.
         """
         instance.save()
 


Test patch:
diff --git a/tests/core/tests/test_resources/test_modelresource/test_data_import.py b/tests/core/tests/test_resources/test_modelresource/test_data_import.py
--- a/tests/core/tests/test_resources/test_modelresource/test_data_import.py
+++ b/tests/core/tests/test_resources/test_modelresource/test_data_import.py
@@ -125,3 +125,23 @@ class DummyConnection:
         )
         self.assertEqual(result.rows[0].row_values.get("name"), None)
         self.assertEqual(result.rows[0].row_values.get("author_email"), None)
+
+    @ignore_widget_deprecation_warning
+    def test_import_data_new_override_do_instance_save(self):
+        class CustomDoInstanceSave(BookResource):
+            is_create = False
+
+            def do_instance_save(self, instance, is_create):
+                self.is_create = is_create
+                super().do_instance_save(instance, is_create)
+
+        Book.objects.all().delete()
+        self.assertEqual(0, Book.objects.count())
+        self.resource = CustomDoInstanceSave()
+        self.assertFalse(self.resource.is_create)
+
+        result = self.resource.import_data(self.dataset, raise_errors=True)
+
+        self.assertFalse(result.has_errors())
+        self.assertEqual(1, Book.objects.count())
+        self.assertTrue(self.resource.is_create)
Repository: ros/rosdistro

Issue:
the check script should make sure there are no spaces in the value
I had written a key for OpenCV to be 
saucy: [libopencv-dev python-opencv]
instead of:
saucy: [libopencv-dev, python-opencv]

And then got the error on the buildfarm: 
dpkg-source: warning: can't parse dependency libopencv-dev python-opencv

Values in the mapping should be checked to not contain spaces.



Discussion:

Resolving patch:
diff --git a/scripts/check_rosdep.py b/scripts/check_rosdep.py
--- a/scripts/check_rosdep.py
+++ b/scripts/check_rosdep.py
@@ -154,6 +154,21 @@ def my_assert(val):
     print_test("building yaml dict...")
     try:
         ydict = yaml.load(buf)
+
+        # ensure that values don't contain whitespaces
+        def walk(node):
+            if isinstance(node, dict):
+                for key, value in node.items():
+                    walk(key)
+                    walk(value)
+            if isinstance(node, list):
+                for value in node:
+                    walk(value)
+            if isinstance(node, str) and re.search(r'\s', node):
+                    print_err("value '%s' must not contain whitespaces" % node)
+                    my_assert(False)
+        walk(ydict)
+
     except Exception as e:
         print_err("could not build the dict: %s" % (str(e)))
         my_assert(False)


Test patch:
Repository: Chia-Network/chia-blockchain

Issue:
Typo
https://github.com/Chia-Network/chia-blockchain/blob/ec0a4cec4bc154e4918d34a5c389b47074fa645b/chia/cmds/plots.py#L128


Discussion:

Resolving patch:
diff --git a/chia/cmds/init.py b/chia/cmds/init.py
--- a/chia/cmds/init.py
+++ b/chia/cmds/init.py
@@ -15,7 +15,7 @@ def init_cmd(ctx: click.Context, create_certs: str):
     Create a new configuration or migrate from previous versions to current
 
     \b
-    Follow these steps to create new certifcates for a remote harvester:
+    Follow these steps to create new certificates for a remote harvester:
     - Make a copy of your Farming Machine CA directory: ~/.chia/[version]/config/ssl/ca
     - Shut down all chia daemon processes with `chia stop all -d`
     - Run `chia init -c [directory]` on your remote harvester,
diff --git a/chia/cmds/keys_funcs.py b/chia/cmds/keys_funcs.py
--- a/chia/cmds/keys_funcs.py
+++ b/chia/cmds/keys_funcs.py
@@ -21,7 +21,7 @@ def generate_and_print():
     mnemonic = generate_mnemonic()
     print("Generating private key. Mnemonic (24 secret words):")
     print(mnemonic)
-    print('Note that this key has not been added to the keychain. Run chia keys add_seed -m "[MNEMONICS]" to add')
+    print("Note that this key has not been added to the keychain. Run chia keys add")
     return mnemonic
 
 
diff --git a/chia/cmds/plots.py b/chia/cmds/plots.py
--- a/chia/cmds/plots.py
+++ b/chia/cmds/plots.py
@@ -125,7 +125,7 @@ def __init__(self):
             self.exclude_final_dir = exclude_final_dir
 
     if size < 32 and not override_k:
-        print("k=32 is the minimun size for farming.")
+        print("k=32 is the minimum size for farming.")
         print("If you are testing and you want to use smaller size please add the --override-k flag.")
         sys.exit(1)
     elif size < 25 and override_k:


Test patch: