GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Allow a package to resolve its own resources simply by jaraco · Pull Request #260 · python/importlib_resources

Conversation

@jaraco

@jaraco jaraco commented Jul 23, 2022

Copy link
Copy Markdown
Member

Fixes #259.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jaraco
jaraco commented Jul 23, 2022
View reviewed changes
Comment thread importlib_resources/_common.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@jaraco

jaraco commented Jul 23, 2022

Copy link
Copy Markdown
Member Author

An issue I found with this implementation is that a call to files(__main__) will result in an error because __main__.__spec__ is None... and while it's not common to call files(__main__) or files('__main__'), it would probably not be uncommon for someone to call files() from __main__.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jaraco
jaraco force-pushed the feature/implicit-here branch 2 times, most recently from cb223fd to 3b6fb35 Compare July 23, 2022 16:41
@jaraco
jaraco force-pushed the feature/203-non-package-modules branch 2 times, most recently from 1f3c226 to 8c3edeb Compare October 5, 2022 14:30
@jaraco

jaraco commented Oct 5, 2022

Copy link
Copy Markdown
Member Author

An issue I found with this implementation is that a call to files(__main__) will result in an error because __main__.__spec__ is None... and while it's not common to call files(__main__) or files('__main__'), it would probably not be uncommon for someone to call files() from __main__.

I'm tempted to explicitly support __main__ to make that use-case easy and congruent to others.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jaraco
jaraco force-pushed the feature/implicit-here branch 6 times, most recently from 4561cd8 to 9cd57a6 Compare October 5, 2022 16:02
@jaraco

jaraco commented Oct 5, 2022

Copy link
Copy Markdown
Member Author

I'm tempted to explicitly support __main__ to make that use-case easy and congruent to others.

In the latest patch, I'm no longer able to replicate this issue, so I'm declaring it a non-issue:

 importlib_resources feature/implicit-here $ cat foo.py
import importlib_resources as res


def main():
    print(res.files())


__name__ == '__main__' and main()
 importlib_resources feature/implicit-here $ .tox/python/bin/python -m foo
/Users/jaraco/code/python/importlib_resources
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jaraco
jaraco marked this pull request as ready for review October 5, 2022 16:20
@jaraco
jaraco force-pushed the feature/implicit-here branch from 9cd57a6 to ef21c53 Compare October 5, 2022 17:26
Base automatically changed from feature/203-non-package-modules to main October 7, 2022 23:47
jaraco added 2 commits October 7, 2022 19:51
@jaraco
Add test capturing expectation.
8bb0635
@jaraco
Extract fixture for SiteDir.
38f789d
@jaraco
jaraco force-pushed the feature/implicit-here branch from ef21c53 to cc1423f Compare October 7, 2022 23:53
@jaraco
Implement caller inference to allow files() to be called without …
e15a6b7
…any parameter.
@jaraco
jaraco force-pushed the feature/implicit-here branch from cc1423f to e15a6b7 Compare October 8, 2022 00:17
@jaraco
Update changelog
d34eeac
@jaraco
jaraco merged commit 4ff0b1b into main Oct 8, 2022
@jaraco
jaraco deleted the feature/implicit-here branch October 8, 2022 00:36
@mkunesch mkunesch mentioned this pull request Oct 10, 2022
TypeError: None not a valid annotation (since PR #260) #270
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

Sprint
Archived in project

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Provide a simple syntax to load resources from __here__

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@jaraco
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.