Skip to content

Locale independent date serialization - #4977

Merged
peterjc merged 4 commits into
biopython:masterfrom
bryan-brancotte:genbank-date-locale-independent-and-warning
Mar 21, 2025
Merged

peterjc merged 4 commits into
biopython:masterfrom
bryan-brancotte:genbank-date-locale-independent-and-warning

Conversation

@bryan-brancotte

Copy link
Copy Markdown
Contributor
  • I hereby agree to dual licence this and any previous contributions under both
    the Biopython License Agreement AND the BSD 3-Clause License.

  • I have read the CONTRIBUTING.rst file, have run pre-commit
    locally, and understand that continuous integration checks will be used to
    confirm the Biopython unit tests and style checks pass with these changes.

  • I have added my name to the alphabetical contributors listings in the files
    NEWS.rst and CONTRIB.rst as part of this pull request, am listed
    already, or do not wish to be listed. (This acknowledgement is optional.)

Locale independent date serialization when writing GenBank file. Also added support for datetime.date.
Added test with various local known to make the former serialization fail (when available).

Show a warning when writing a file with an invalide date format

Closes #4972

Add test with various locale
Add test with datetime.date
Closes biopython#4972
@bryan-brancotte
bryan-brancotte force-pushed the genbank-date-locale-independent-and-warning branch from 82a6422 to 886fe9f Compare March 21, 2025 11:20
@bryan-brancotte

Copy link
Copy Markdown
Contributor Author

The tests try using various locale, which are not by default in ubuntu-latest, and thus wont be tested in the CI, while they will be tested on a local computer if locale is installed manually. We can add it to the CI, but it add 30MB of download, some more time. I don't know what one would prefer

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 82f5f7626..84c9493ad 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -55,6 +55,14 @@ jobs:
       run: |
         pre-commit run --files ${{ steps.changed-files.outputs.all_changed_files }}
 
+    - name: Install locale
+      run: |
+        sudo apt-get update
+        echo "fr_FR.UTF-8 UTF-8" | sudo tee -a /etc/locale.gen
+        echo "de_DE.UTF-8 UTF-8" | sudo tee -a /etc/locale.gen
+        echo "pt_BR.UTF-8 UTF-8" | sudo tee -a /etc/locale.gen
+        sudo apt-get -y install locales
+
   # Cache pip & python dependencies for Linux runner
   # since it is used in most actions.
   # Adapted from: https://medium.com/ai2-blog/python-caching-in-github-actions-e9452698e98d

P.S: diff not tested

@peterjc peterjc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't install the extra locales in the CI just for this test - the overhead seems excessive.

Comment thread Bio/SeqIO/InsdcIO.py Resolved
Comment thread Bio/SeqIO/InsdcIO.py Resolved
Comment thread Bio/SeqIO/InsdcIO.py Resolved
@peterjc
peterjc enabled auto-merge (squash) March 21, 2025 15:35
@peterjc
peterjc merged commit 79759c8 into biopython:master Mar 21, 2025
@codecov

codecov Bot commented Mar 21, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.27%. Comparing base (062eb51) to head (143bae0).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4977      +/-   ##
==========================================
+ Coverage   85.37%   86.27%   +0.90%     
==========================================
  Files         282      282              
  Lines       59397    59399       +2     
==========================================
+ Hits        50708    51246     +538     
+ Misses       8689     8153     -536     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Date ignored in Genbank writer with not-english locale

2 participants