internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: internetarchive/openlibrary

Issue:
Add `publish_date` of 1900-01-01 to the list of suspect publication dates for AMZ and BWB
### Problem

In #8969 / #9009, we cleared the `publish_date` field when it was "January 1, 1900" or "1900" when an AMZ or BWB.

It turns out "1900-01-01" is another suspect date. @hornc removed all such existing dates (see, e.g. https://openlibrary.org/books/OL49656996M/The_relief_of_Ladysmith?m=diff&b=2), but we should prevent such dates from being added in the future. 

I checked whether it was worth adding additional permutations of this date, but it seems this may be the last one:
- https://openlibrary.org/query.json?type=/type/edition&publish_date~=1-1-1900 (none)
- https://openlibrary.org/query.json?type=/type/edition&publish_date~=01-01-1900 (none)
- https://openlibrary.org/query.json?type=/type/edition&publish_date~=01/01/1900 (none)
- https://openlibrary.org/query.json?type=/type/edition&publish_date~=1/1/1900 (one entry)
- https://openlibrary.org/query.json?type=/type/edition&publish_date~=1900-1-1 (none)

### Reproducing the bug

_No response_

### Context

_No response_

### Notes from this Issue's Lead

#### Proposal & constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->

#### Related files
<!-- Files related to this issue; this is super useful for new contributors who might want to help! If you're not sure, leave this blank; a maintainer will add them. -->

#### Stakeholders
<!-- @ tag stakeholders of this bug -->
@mekarpeles 
@hornc 


Discussion:

Resolving patch:
diff --git a/openlibrary/catalog/add_book/__init__.py b/openlibrary/catalog/add_book/__init__.py
--- a/openlibrary/catalog/add_book/__init__.py
+++ b/openlibrary/catalog/add_book/__init__.py
@@ -67,7 +67,7 @@
 re_normalize = re.compile('[^[:alphanum:] ]', re.U)
 re_lang = re.compile('^/languages/([a-z]{3})$')
 ISBD_UNIT_PUNCT = ' : '  # ISBD cataloging title-unit separator punctuation
-SUSPECT_PUBLICATION_DATES: Final = ["1900", "January 1, 1900"]
+SUSPECT_PUBLICATION_DATES: Final = ["1900", "January 1, 1900", "1900-01-01"]
 SOURCE_RECORDS_REQUIRING_DATE_SCRUTINY: Final = ["amazon", "bwb", "promise"]
 
 


Test patch:
Repository: internetarchive/openlibrary

Issue:
Should default return type for is_loaned_out_on_ia should be False not None?
### Problem



#### Evidence / Screenshot
https://github.com/internetarchive/openlibrary/blob/ce273d84cf14f66c5e07b081247a1c3c342666ff/openlibrary/core/lending.py#L564-L572

This code returns `None`.
I'm fairly certain we should not return `None`. Based on how it is used, it is evaluating to `False`. As in "false, the book isn't loaned out because there was an error". In my opinion, we should probably default to returning `True` instead.

I've gotten a bit stumped a few times trying to follow the code. However, at least the code path ending here with waitinglists seems like it would get an error from this logic.

https://github.com/internetarchive/openlibrary/blob/1f614a196ae0fdc63b28f47539c85f2a7a93971a/openlibrary/templates/admin/waitinglists.html#L34-L39


#### Relevant URL(s)


### Reproducing the bug

_No response_

### Context

Found during #9117

### Notes from this Issue's Lead

#### Proposal & constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->

#### Related files
<!-- Files related to this issue; this is super useful for new contributors who might want to help! If you're not sure, leave this blank; a maintainer will add them. -->

#### Stakeholders
<!-- @ tag stakeholders of this bug -->



Discussion:
There's an open question about what to do when a title is not borrowable at all, which is probably what None was trying to communicate. True is actually misleading in this case, because it's not the case that the item is lent out, it's the case that the title is simply not borrowable and we don't want the UI to communicate that the title is checked out.
@mekarpeles I see what you mean.

In that case I think the solution is one level up is to check if `is_loaned_out_on_ia is True`.
This way it when we return None `is_loaned_out` doesn't think it's available.

Should we make that change?

https://github.com/internetarchive/openlibrary/blob/ce273d84cf14f66c5e07b081247a1c3c342666ff/openlibrary/core/lending.py#L543-L556

Yes I think that's reasonable

Resolving patch:
diff --git a/openlibrary/core/lending.py b/openlibrary/core/lending.py
--- a/openlibrary/core/lending.py
+++ b/openlibrary/core/lending.py
@@ -551,7 +551,7 @@ def is_loaned_out(identifier: str) -> bool:
     return (
         is_loaned_out_on_ol(identifier)
         or is_loaned_out_on_acs4(identifier)
-        or is_loaned_out_on_ia(identifier)
+        or (is_loaned_out_on_ia(identifier) is True)
     )
 
 
@@ -561,7 +561,7 @@ def is_loaned_out_on_acs4(identifier: str) -> bool:
     return item.has_loan()
 
 
-def is_loaned_out_on_ia(identifier: str):
+def is_loaned_out_on_ia(identifier: str) -> bool | None:
     """Returns True if the item is checked out on Internet Archive."""
     url = "https://archive.org/services/borrow/%s?action=status" % identifier
     try:


Test patch:
Repository: internetarchive/openlibrary

Issue:
Notes update handler should redirect immediately on unauthenticated request
### Problem

Today, whenever an unauthenticated request is sent to our notes update endpoint, some unnecessary processing is occurring before the handler redirects. 

#### Evidence / Screenshot

#### Relevant URL(s)


### Reproducing the bug

1. Go to ...
2. Do ...

* Expected behavior:
* Actual behavior:


### Context

- Browser (Chrome, Safari, Firefox, etc): N/A
- OS (Windows, Mac, etc): N/A
- Logged in (Y/N): N
- Environment (prod, dev, local): prod


### Notes from this Issue's Lead

#### Proposal & constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->
If a request to this endpoint is unauthenticated, immediately redirect.
#### Related files
<!-- Files related to this issue; this is super useful for new contributors who might want to help! If you're not sure, leave this blank; a maintainer will add them. -->

#### Stakeholders
<!-- @ tag stakeholders of this bug -->



Discussion:

Resolving patch:
diff --git a/openlibrary/plugins/openlibrary/api.py b/openlibrary/plugins/openlibrary/api.py
--- a/openlibrary/plugins/openlibrary/api.py
+++ b/openlibrary/plugins/openlibrary/api.py
@@ -227,14 +227,14 @@ def POST(self, work_id):
         :return: the note
         """
         user = accounts.get_current_user()
+        if not user:
+            raise web.seeother('/account/login?redirect=/works/%s' % work_id)
+
         i = web.input(notes=None, edition_id=None, redir=None)
         edition_id = (
             int(extract_numeric_id_from_olid(i.edition_id)) if i.edition_id else -1
         )
 
-        if not user:
-            raise web.seeother('/account/login?redirect=/works/%s' % work_id)
-
         username = user.key.split('/')[2]
 
         def response(msg, status="success"):


Test patch:
Repository: internetarchive/openlibrary

Issue:
enable ruff rule: ambiguous-unicode-character-docstring (RUF002)
### Problem

This rule is enabled by default and we manually disabled it for some reason.

I don't think there is a good reason to have this disabled. We shouldn't have ambiguous characters in our docstrings unless absolutely needed (like the one example where we added an exception).

#### Evidence / Screenshot

#### Relevant URL(s)
https://docs.astral.sh/ruff/rules/ambiguous-unicode-character-docstring/#ambiguous-unicode-character-docstring-ruf002

### Reproducing the bug

1. Go to ...
2. Do ...

* Expected behavior:
* Actual behavior:


### Context

- Browser (Chrome, Safari, Firefox, etc):
- OS (Windows, Mac, etc):
- Logged in (Y/N): Y
- Environment (prod, dev, local): prod


### Notes from this Issue's Lead

#### Proposal & constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->

#### Related files
<!-- Files related to this issue; this is super useful for new contributors who might want to help! If you're not sure, leave this blank; a maintainer will add them. -->

#### Stakeholders
<!-- @ tag stakeholders of this bug -->



Discussion:

Resolving patch:
diff --git a/openlibrary/plugins/upstream/addbook.py b/openlibrary/plugins/upstream/addbook.py
--- a/openlibrary/plugins/upstream/addbook.py
+++ b/openlibrary/plugins/upstream/addbook.py
@@ -169,7 +169,7 @@ def encode_url_path(url: str) -> str:
     '/'
     >>> encode_url_path('/books/OL11M/进入该海域?mode=add-work')
     '/books/OL11M/%E8%BF%9B%E5%85%A5%E8%AF%A5%E6%B5%B7%E5%9F%9F?mode=add-work'
-    """
+    """  # noqa: RUF002
     result = urllib.parse.urlparse(url)
     correct_path = "/".join(urllib.parse.quote(part) for part in result.path.split("/"))
     result = result._replace(path=correct_path)
diff --git a/scripts/cron_watcher.py b/scripts/cron_watcher.py
--- a/scripts/cron_watcher.py
+++ b/scripts/cron_watcher.py
@@ -6,7 +6,7 @@
 If not sitemaps updated for this YYYY-MM on www
 If not partner dumps uploaded for this YYYY-MM on archive.org
 If no imports in last 48 hours (i.e. 2 days)
-If DD>17 for YYYY-MM and bwb `batchname` doesn’t exist in import psql table
+If DD>17 for YYYY-MM and bwb `batchname` doesn't exist in import psql table
 Send daily email with failures only or slack failures
 """
 


Test patch:
Repository: internetarchive/openlibrary

Issue:
Updating Slack "Staff PRs" notifications to be more specific
<!-- IMPORTANT: Before posting, be sure to redact or remove sensitive data, such as passwords, secret keys, session cookies, etc. -->

When our daily slack bot runs to tell us of new staff PRs we want to ignore: 
- `needs:submitter`
- `draft`
- `blocked`

<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

### Describe the problem that you'd like solved
<!-- A clear and concise description of what you want to happen. -->

### Proposal & Constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->

<!-- Which suggestions or requirements should be considered for how feature needs to appear or be implemented? -->

### Additional context
<!-- Add any other context or screenshots about the feature request here. -->

### Stakeholders
<!-- @ tag stakeholders of this bug -->





Discussion:

Resolving patch:
diff --git a/scripts/pr_slack_digest.py b/scripts/pr_slack_digest.py
--- a/scripts/pr_slack_digest.py
+++ b/scripts/pr_slack_digest.py
@@ -33,8 +33,18 @@ def send_slack_message(message: str):
         'Priority: 0': '🚨 ',
         'Priority: 1': '❗️ ',
     }
+
+    INCLUDE_AUTHORS = ['mekarpeles', 'cdrini', 'scottbarnes', 'jimchamp']
+    EXCLUDE_LABELS = [
+        'Needs: Submitter Input',
+        'State: Blocked',
+    ]
+    query = 'repo:internetarchive/openlibrary is:open is:pr -is:draft'
     # apparently `author` acts like an OR in this API and only this API -_-
-    query = "repo:internetarchive/openlibrary is:open is:pr author:cdrini author:jimchamp author:mekarpeles author:scottbarnes -is:draft"
+    included_authors = " ".join([f"author:{author}" for author in INCLUDE_AUTHORS])
+    excluded_labels = " ".join([f'-label:"{label}"' for label in EXCLUDE_LABELS])
+    query = f'{query} {included_authors} {excluded_labels}'
+
     prs = requests.get(
         "https://api.github.com/search/issues",
         params={


Test patch:
Repository: internetarchive/openlibrary

Issue:
`sentry` object imported before instantiation
### Problem

The `sentry` object that is used in the account registration flow is never instantiated.

#### Evidence / Screenshot
Link to [Sentry event](https://sentry.archive.org/organizations/ia-ux/issues/496719/?query=is%3Aunresolved&referrer=issue-stream) that was triggered by this issue.

#### Relevant URL(s)
openibrary.org/account/create

### Reproducing the bug

1. Go to /account/create
2. Submit the form with invalid data
3. Check the error logs

* Expected behavior:
* Actual behavior:


### Context

- Browser (Chrome, Safari, Firefox, etc):
- OS (Windows, Mac, etc):
- Logged in (Y/N): Y
- Environment (prod, dev, local): prod


### Notes from this Issue's Lead

#### Proposal & constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->

#### Related files
<!-- Files related to this issue; this is super useful for new contributors who might want to help! If you're not sure, leave this blank; a maintainer will add them. -->

#### Stakeholders
<!-- @ tag stakeholders of this bug -->



Discussion:

Resolving patch:
diff --git a/openlibrary/plugins/upstream/account.py b/openlibrary/plugins/upstream/account.py
--- a/openlibrary/plugins/upstream/account.py
+++ b/openlibrary/plugins/upstream/account.py
@@ -32,7 +32,6 @@
 )
 from openlibrary.core.observations import Observations
 from openlibrary.core.ratings import Ratings
-from openlibrary.plugins.openlibrary.sentry import sentry
 from openlibrary.core.follows import PubSub
 
 from openlibrary.plugins.recaptcha import recaptcha
@@ -326,6 +325,8 @@ def POST(self):
                 )
             except OLAuthenticationError as e:
                 f.note = get_login_error(e.__str__())
+                from openlibrary.plugins.openlibrary.sentry import sentry
+
                 if sentry.enabled:
                     sentry.capture_exception(e)
 


Test patch:
Repository: internetarchive/openlibrary

Issue:
Add monthly cron to run Cover Server Archival
Related to #6822 and #7691

# Proposed Recipe

For now, until there's a fully automatic cron and the code is robust enough to be run stand-alone without oversight, here is a way for us to catch-up on our backlog of non-archived covers:

```
ssh -A ol-covers0
cd /opt/openlibrary

CONTAINER=$(docker ps | grep -oP 'openlibrary_covers_run_\S+')
if [ -z "$CONTAINER" ]; then
    COMPOSE_FILE="compose.yaml:compose.production.yaml" HOSTNAME=$HOSTNAME docker compose run --rm -d covers bash
fi

CONTAINER=$(docker ps | grep -oP 'openlibrary_covers_run_\S+')
# Will reattach to an existing session else create a new one
# Container will start bash, run python, & return to bash on exit
docker exec -it $CONTAINER screen -DR python bash -c 'python && bash'

from openlibrary.coverstore import config
from openlibrary.coverstore.server import load_config
load_config("/olsystem/etc/openlibrary.yml")
load_config("/olsystem/etc/coverstore.yml")
from openlibrary.coverstore import archive
archive.archive()
archive.Batch.process_pending(upload=True, finalize=True, test=False)
```

**Longer-term**

We likely want one cron that performs archival, e.g.
```
from openlibrary.coverstore import config
from openlibrary.coverstore.server import load_config
load_config("/olsystem/etc/openlibrary.yml")
load_config("/olsystem/etc/coverstore.yml")
from openlibrary.coverstore import archive
archive.archive()
```

And then another cron which runs upload + cleanup (i.e. "finalize")
```
archive.Batch.process_pending(upload=True, finalize=True, test=False)
```


Discussion:

Resolving patch:
diff --git a/openlibrary/coverstore/archive.py b/openlibrary/coverstore/archive.py
--- a/openlibrary/coverstore/archive.py
+++ b/openlibrary/coverstore/archive.py
@@ -14,6 +14,7 @@
 
 from openlibrary.coverstore import config, db
 from openlibrary.coverstore.coverlib import find_image_path
+from scripts.solr_builder.solr_builder.fn_to_cli import FnToCLI
 
 
 ITEM_SIZE = 1_000_000
@@ -509,3 +510,16 @@ def get_last_file_in_zip(cls, zip_file_path):
             file_list = zip_file.namelist()
             if file_list:
                 return max(file_list)
+
+
+def main(openlibrary_yml: str, coverstore_yml: str, dry_run: bool = False):
+    from openlibrary.coverstore.server import load_config
+
+    load_config(openlibrary_yml)
+    load_config(coverstore_yml)
+    archive()
+    Batch.process_pending(upload=True, finalize=True, test=dry_run)
+
+
+if __name__ == '__main__':
+    FnToCLI(main).run()


Test patch:
Repository: internetarchive/openlibrary

Issue:
add a failing author name test
<!-- What issue does this PR close? -->
Demonstrates a bug in #9003

<!-- What does this PR achieve? [feature|hotfix|fix|refactor] -->

`Drini` -> `ini`

**Expected:**
`Drini` -> `Drini`

😉 

### Technical
<!-- What should be noted about the implementation? -->

### Testing
<!-- Steps for reviewer to reproduce/verify what this PR does/fixes. -->

### Screenshot
<!-- If this PR touches UI, please post evidence (screenshots) of it behaving correctly. -->

### Stakeholders
<!-- @ tag the lead (as labeled on the issue) and other stakeholders -->
@cdrini 
@scottbarnes 

<!-- Attribution Disclaimer: By proposing this pull request, I affirm to have made a best-effort and exercised my discretion to make sure relevant sections of this code which substantially leverage code suggestions, code generation, or code snippets from sources (e.g. Stack Overflow, GitHub) have been annotated with basic attribution so reviewers & contributors may have confidence and access to the correct context to evaluate and use this code. -->



Discussion:
D: Thank you for catching this, @hornc.

Resolving patch:
diff --git a/openlibrary/catalog/add_book/load_book.py b/openlibrary/catalog/add_book/load_book.py
--- a/openlibrary/catalog/add_book/load_book.py
+++ b/openlibrary/catalog/add_book/load_book.py
@@ -236,11 +236,11 @@ def remove_author_honorifics(name: str) -> str:
         (
             honorific
             for honorific in HONORIFICS
-            if name.casefold().startswith(honorific)
+            if name.casefold().startswith(f"{honorific} ")  # Note the trailing space.
         ),
         None,
     ):
-        return name[len(honorific) :].lstrip() or name
+        return name[len(f"{honorific} ") :].lstrip() or name
 
     return name
 


Test patch:
diff --git a/openlibrary/catalog/add_book/tests/test_load_book.py b/openlibrary/catalog/add_book/tests/test_load_book.py
--- a/openlibrary/catalog/add_book/tests/test_load_book.py
+++ b/openlibrary/catalog/add_book/tests/test_load_book.py
@@ -83,6 +83,7 @@ def add_three_existing_authors(self, mock_site):
     @pytest.mark.parametrize(
         ["name", "expected"],
         [
+            ("Drake von Drake", "Drake von Drake"),
             ("Dr. Seuss", "Dr. Seuss"),
             ("dr. Seuss", "dr. Seuss"),
             ("Dr Seuss", "Dr Seuss"),
Repository: bramstroker/homeassistant-powercalc

Issue:
Measurement - Crash when nudging on first iteration
The App crashes when trying to nudge on the first iteration of the measurement loop.

When fixing this issue, I also realised that the new power value returned from the nudge_and_remeasure method is ignored and the power value of the last iteration saved.

Error message:
```
2022-10-23 13:40:20,659 [WARNING] Measurement is stuck, Nudging
Traceback (most recent call last):
  File "/app/measure.py", line 912, in <module>
    main()
  File "/app/measure.py", line 906, in main
    measure.start()
  File "/app/measure.py", line 336, in start
    _LOGGER.info(f"Measured power: {power}")
UnboundLocalError: local variable 'power' referenced before assignment
```


Discussion:

Resolving patch:
diff --git a/utils/measure/measure.py b/utils/measure/measure.py
--- a/utils/measure/measure.py
+++ b/utils/measure/measure.py
@@ -322,7 +322,7 @@ def start(self) -> None:
                 try:
                     power = self.take_power_measurement(variation_start_time)
                 except OutdatedMeasurementError as error:
-                    self.nudge_and_remeasure(self.color_mode, variation)
+                    power = self.nudge_and_remeasure(self.color_mode, variation)
                 except ZeroReadingError as error:
                     self.num_0_readings += 1
                     _LOGGER.warning(f"Discarding measurement: {error}")


Test patch:
Repository: bramstroker/homeassistant-powercalc

Issue:
Upgrade to Python 3.12
After HA 2024.2.0 is release we could upgrade alle python dependencies to Python 3.12
Also all github action can run on python 3.12


Discussion:

Resolving patch:
diff --git a/custom_components/powercalc/sensors/utility_meter.py b/custom_components/powercalc/sensors/utility_meter.py
--- a/custom_components/powercalc/sensors/utility_meter.py
+++ b/custom_components/powercalc/sensors/utility_meter.py
@@ -21,7 +21,8 @@
 from custom_components.powercalc.const import (
     CONF_CREATE_UTILITY_METERS,
     CONF_ENERGY_SENSOR_PRECISION,
-    CONF_IGNORE_UNAVAILABLE_STATE, CONF_UTILITY_METER_OFFSET,
+    CONF_IGNORE_UNAVAILABLE_STATE,
+    CONF_UTILITY_METER_OFFSET,
     CONF_UTILITY_METER_TARIFFS,
     CONF_UTILITY_METER_TYPES,
     DEFAULT_ENERGY_SENSOR_PRECISION,


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -6,7 +6,7 @@ on:
   pull_request:
 
 env:
-  POETRY_VERSION: 1.5.1
+  POETRY_VERSION: 1.7.1
 
 jobs:
   tests:
@@ -18,7 +18,7 @@ jobs:
       - name: Setup Python
         uses: actions/setup-python@v4
         with:
-          python-version: '3.11'
+          python-version: '3.12'
       - name: Load cached Poetry installation
         id: cached-poetry
         uses: actions/cache@v3
Repository: dynamiqs/dynamiqs

Issue:
implement a ver() method
As a user if I want to make sure my setup is up to date with the latest version, I want to be able to call dq.ver() to know which version I am running


Discussion:
Thanks for the suggestion, we definitely need this! Using `package.__version__` is quasi-standard to get the installed version of a Python package, so it's probably the best way to go. I'll work on this.
Meanwhile you can always drop a `pip list | grep dynamiqs` in your terminal 😉 

Resolving patch:
diff --git a/dynamiqs/__init__.py b/dynamiqs/__init__.py
--- a/dynamiqs/__init__.py
+++ b/dynamiqs/__init__.py
@@ -1,4 +1,9 @@
+from importlib.metadata import version
+
 from .mesolve import mesolve
 from .sesolve import sesolve
 from .smesolve import smesolve
 from .utils import *
+
+# get version from pyproject.toml
+__version__ = version(__package__)


Test patch: