Skip to content

Support Traversable for file= in config.get#50

Merged
harell merged 10 commits into
masterfrom
copilot/add-support-for-traversable
Mar 20, 2026
Merged

Support Traversable for file= in config.get#50
harell merged 10 commits into
masterfrom
copilot/add-support-for-traversable

Conversation

Copilot AI commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

config.get(file=files("pkg.config").joinpath("sites.yaml")) raises a pyright reportArgumentType error because file only accepts str | Path, not Traversable.

Changes

  • src/ruru/config.py: Widen file parameter type to str | Path | Traversable. When a Traversable is passed, it's used directly — find_config_file (parent directory search) is bypassed since it doesn't apply to package resources.
  • tests/ruru/config/test_config.py: Add test exercising the Traversable code path via a concrete Traversable wrapper.
from importlib.resources import files
from ruru import config

# Now accepted by both runtime and type checkers
cfg = config.get(file=files("mypackage.config").joinpath("sites.yaml"))
Original prompt

This section details on the original issue you should resolve

<issue_title>config.get should support Traversable for file=</issue_title>
<issue_description>_sites_cfg = ruru_config.get(file=files("ghgmod.config").joinpath("sites.yaml"))

Give the pyright error

Argument of type "Traversable" cannot be assigned to parameter "file" of type "str | Path" in function "get"
  Type "Traversable" is not assignable to type "str | Path"
    "Traversable" is not assignable to "str"
    "Traversable" is not assignable to "Path"Pylance[reportArgumentType](https://github.com/microsoft/pylance-release/blob/main/docs/diagnostics/reportArgumentType.md)

Whereas this should be acceptable. We should add support for Traversable via the type annotation system.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for Traversable in config.get file parameter Support Traversable for file= in config.get Mar 19, 2026
Copilot AI requested a review from nathanjmcdougall March 19, 2026 22:41
Comment thread src/ruru/config.py Outdated
file: Configuration file to read from (defaults to "config.yml"). If the file
isn't found at the location specified, then parent directories are
searched for a file of the same name.
file: Configuration file to read from (defaults to "config.yml"). Accepts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@copilot remove the type information from these docstrings

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed type references from the docstring in 4144ffe.

Comment thread src/ruru/config.py Outdated
Comment thread src/ruru/config.py Outdated
…r, fix Python 3.10 import

Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
@t-t-sonarqube

t-t-sonarqube Bot commented Mar 20, 2026

Copy link
Copy Markdown

@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review March 20, 2026 00:50
@nathanjmcdougall nathanjmcdougall requested a review from harell March 20, 2026 00:50
@harell harell merged commit 69cb620 into master Mar 20, 2026
15 checks passed
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.

config.get should support Traversable for file=

3 participants