Skip to content

Refactor SQLiteTLE and modernize codebase: remove .format, drop (object), adopt pathlib, and split SQLite tests#224

Closed
JaskRendix wants to merge 1 commit intopytroll:mainfrom
JaskRendix:cleanup
Closed

Refactor SQLiteTLE and modernize codebase: remove .format, drop (object), adopt pathlib, and split SQLite tests#224
JaskRendix wants to merge 1 commit intopytroll:mainfrom
JaskRendix:cleanup

Conversation

@JaskRendix
Copy link
Contributor

PR updates the SQLiteTLE class and surrounding code to use modern Python features. It removes .format() string formatting, replaces os.path with pathlib where appropriate, and drops the old‑style (object) inheritance. The SQLite test suite is moved out of the general TLE tests into a new file focused on SQLite behavior. The refactor keeps behavior unchanged and all existing tests pass.

  • Tests added
  • Fully documented

@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

❌ Patch coverage is 98.43750% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.66%. Comparing base (c2cbf0c) to head (fd37042).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pyorbital/tlefile.py 92.15% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #224      +/-   ##
==========================================
+ Coverage   90.46%   90.66%   +0.20%     
==========================================
  Files          19       20       +1     
  Lines        3040     3118      +78     
==========================================
+ Hits         2750     2827      +77     
- Misses        290      291       +1     
Flag Coverage Δ
unittests 90.66% <98.43%> (+0.20%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@JaskRendix JaskRendix force-pushed the cleanup branch 2 times, most recently from 2a90f06 to 7989b17 Compare March 2, 2026 09:18
@djhoese
Copy link
Member

djhoese commented Mar 2, 2026

I'm wondering on the "modern python" stuff if we should adopt pyupgrade (https://github.com/asottile/pyupgrade) to do this automatically in the future.

@JaskRendix
Copy link
Contributor Author

@djhoese you’re right, if we want pyupgrade‑style checks, we just need to enable the UP rules in Ruff. That means adding "UP" to the select list in the [tool.ruff.lint] section of the pyproject.toml.

I thought about adding it already, but I didn’t want to mix it into this PR since I have another pending one that touches some of the same areas. I tried to keep this PR focused on cleaning up specific things and class to avoid creating a messy situation. For example, this PR doesn’t remove the (object) in the Orbital class because the other PR already handles that.

@djhoese
Copy link
Member

djhoese commented Mar 3, 2026

No problem. I'll leave the review of the actual refactoring and functional changes (SQLiteTLE) to the maintainers who have experience with that.

Copy link
Member

@djhoese djhoese left a comment

Choose a reason for hiding this comment

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

I'm OK with this being merged, but I think my general opinion of the str -> pathlib changes is that they are unnecessary and make some of the code more confusing than clearer. I say that as someone who likes pathlib for new code. There is just a bit too much str -> Path -> str conversion here and I'm worried it will introduce bugs (that aren't tested) or will make future functionality more difficult. For example, Path doesn't play well with custom protocols if I remember right so if in the future TLEs come from S3 and there is an S3 URI like s3://tle-bucket/path/to/tle.txt then converting to Path would not work correctly.

In [2]: str(Path("s3://a/b/c/tle.txt"))
Out[2]: 's3:/a/b/c/tle.txt'

Note the single slash. So again, I'm fine with this being merged if other maintainers are as well, but we should be careful about wide sweeping "convert to this other API" style changes.

@JaskRendix
Copy link
Contributor Author

@djhoese I understand the concern regarding Pathlib and potential issues with protocols like S3. Since this refactor introduces unnecessary complexity and risk for future URI support, I will close this PR for now. I'll re-evaluate the changes and may reopen a more focused version later. Apologies for the noise.

@JaskRendix JaskRendix closed this Mar 3, 2026
@JaskRendix JaskRendix deleted the cleanup branch March 3, 2026 20:39
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.

2 participants