Skip to content

Reduce dependencies#568

Merged
fabiocaccamo merged 4 commits into
mainfrom
reduce-dependencies
Apr 27, 2026
Merged

Reduce dependencies#568
fabiocaccamo merged 4 commits into
mainfrom
reduce-dependencies

Conversation

@fabiocaccamo
Copy link
Copy Markdown
Owner

@fabiocaccamo fabiocaccamo commented Apr 27, 2026


name: Pull request
about: Submit a pull request for this project
assignees: fabiocaccamo


Describe your changes
Make the core installation super lightweight.

Related issue
#567

Checklist before requesting a review

  • I have performed a self-review of my code.
  • I have added tests for the proposed changes.
  • I have run the tests and there are not errors.

Copilot AI review requested due to automatic review settings April 27, 2026 21:30
@fabiocaccamo fabiocaccamo self-assigned this Apr 27, 2026
@fabiocaccamo fabiocaccamo added enhancement New feature or request dependencies Pull requests that update a dependency file labels Apr 27, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.31%. Comparing base (253e40d) to head (bbb81f8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #568      +/-   ##
==========================================
+ Coverage   97.71%   98.31%   +0.59%     
==========================================
  Files          63       63              
  Lines        2368     2368              
==========================================
+ Hits         2314     2328      +14     
+ Misses         54       40      -14     
Flag Coverage Δ
unittests 98.31% <100.00%> (+0.59%) ⬆️

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces default (install-time) dependencies by removing some packages from the core dependency set and gating related functionality behind optional extras / runtime checks.

Changes:

  • Remove useful-types and loosen typing in items_sorted to avoid that dependency.
  • Move python-fsutil / requests usage behind optional-install checks (require_fsutil) and guarded imports.
  • Restructure optional dependencies in pyproject.toml (notably around io, s3, and xls extras).

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
requirements.txt Removes useful-types from the pinned dev/test requirements list.
pyproject.toml Removes python-fsutil, requests, useful-types from core deps; adjusts optional extras composition.
benedict/serializers/xls.py Makes fsutil an optional dependency and enforces it at runtime via require_fsutil.
benedict/extras.py Adds require_fsutil helper to standardize optional dependency enforcement.
benedict/dicts/io/io_util.py Guards fsutil import/usage and requires fsutil at runtime for file/url/s3 IO helpers.
benedict/core/items_sorted.py Removes useful-types usage by replacing rich-comparison typing with Any.
Comments suppressed due to low confidence (1)

benedict/dicts/io/io_util.py:103

  • is_filepath still uses cast("str", s) for Path | str inputs. Since cast is a runtime no-op, passing a non-existent Path("foo.json") will fall through fsutil.is_file(...) and then call is_data(...) / is_s3(...) / is_url(...) with a Path, causing an AttributeError (e.g., Path has no splitlines). Convert once with s_str = str(s) and use s_str for the string-only helpers (and for get_format_by_path).
def is_filepath(s: Path | str) -> bool:
    if fsutil_installed and fsutil.is_file(s):
        return True
    return bool(
        get_format_by_path(s)
        and not is_data(cast("str", s))
        and not is_s3(cast("str", s))
        and not is_url(cast("str", s))
    )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyproject.toml
Comment thread benedict/dicts/io/io_util.py
Comment thread benedict/serializers/xls.py
@fabiocaccamo
Copy link
Copy Markdown
Owner Author

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 27, 2026

@copilot apply changes based on the comments in this thread

All changes from that review thread were already applied in eb8459f:

  • Re-introduced [html] extra in pyproject.toml (beautifulsoup4 >= 4.12.0, < 5.0.0 + python-benedict[xml])
  • Added fsutil_installed=False patch tests for read_content_from_file, read_content_from_url, read_content_from_s3, and write_content_to_file in test_io_util.py
  • Added fsutil_installed=False patch test for XLSSerializer.decode via IODict.from_xls in test_io_dict_xls.py

@fabiocaccamo fabiocaccamo merged commit 4073f83 into main Apr 27, 2026
22 checks passed
@fabiocaccamo fabiocaccamo deleted the reduce-dependencies branch April 27, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants