Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Parses module in more robust way for fn gathering #272

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

elijahbenizzy
Copy link
Collaborator

inspect.getmodule(fn) depends on the state of sys.modules. This can break if you're doing repeated parsing -- E.G. running it then wiping sys.modules. Instead, we can just ask the function for its module. It's simpler, and won't break.

[Short description explaining the high-level reason for the pull request]

Changes

How I tested this

Notes

Checklist

  • PR has an informative and human-readable title (this will be pulled into the release notes)
  • Changes are limited to a single goal (no scope creep)
  • Code passed the pre-commit check & code is left cleaner/nicer than when first encountered.
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future TODOs are captured in comments
  • Project documentation has been updated if adding/changing functionality.

#276

This is a little rough -- we need more testing. But it should work.
Followed the spec at it was fairly clean -- using typed dicts, and
validating on decoration. Also restricting to only primitives -- we can
change it later but I want to keep things a lot simpler for now.
inspect.getmodule(fn) depends on the state of sys.modules. This can
break if you're doing repeated parsing -- E.G. running it then wiping
sys.modules. Instead, we can just ask the function for its module. It's
simpler, and won't break.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant