Skip to content

[PYD-617] Remove default for modules parameter of install_auto_tracing - #261

Merged
alexmojaki merged 4 commits into
mainfrom
alex/no-default-auto-trace-modules
Jun 12, 2024
Merged

alexmojaki merged 4 commits into
mainfrom
alex/no-default-auto-trace-modules

Conversation

@alexmojaki

@alexmojaki alexmojaki commented Jun 12, 2024 •

Copy link
Copy Markdown
Contributor

Currently by default:

  • Modules under the root of the current module are traced if no modules are specified
  • An error is raised if modules to be traced have already been imported

This means that providing no arguments will always raise an error about wanting to trace the current module which has obviously already been imported. Either modules or check_imported_modules must be specified. This is a bit weird.

This PR makes things less weird by requiring the user to specify modules. This seems like a case where explicit really is better than implicit.

@linear

linear Bot commented Jun 12, 2024

Copy link
Copy Markdown

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 12, 2024 •

Copy link
Copy Markdown

Deploying logfire-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4b85bd3
Status: ✅  Deploy successful!
Preview URL: https://a9f85f4a.logfire-docs.pages.dev
Branch Preview URL: https://alex-no-default-auto-trace-m.logfire-docs.pages.dev

View logs

@codecov

codecov Bot commented Jun 12, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@alexmojaki
alexmojaki marked this pull request as ready for review June 12, 2024 11:20
@alexmojaki
alexmojaki requested a review from davidhewitt June 12, 2024 11:20

@davidhewitt davidhewitt left a comment

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.

LGTM with a suggestion to add more tests for related cases :)

Comment on lines 26 to 29
if isinstance(modules, Sequence): # pragma: no branch
modules = modules_func_from_sequence(modules)

if not callable(modules): # pragma: no cover

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.

Maybe if / elif here? This seems like a prime opportunity to add tests for callable and also wrong-type inputs.

Suggested change
if isinstance(modules, Sequence): # pragma: no branch
modules = modules_func_from_sequence(modules)
if not callable(modules): # pragma: no cover
if isinstance(modules, Sequence):
modules = modules_func_from_sequence(modules)
elif not callable(modules):

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.

Added a test for the wrong type. Testing a callable feels a bit redundant. Not using elif to make it clear that the sequence gets converted to a callable, so modules is always eventually a callable.

@alexmojaki
alexmojaki enabled auto-merge (squash) June 12, 2024 12:31
@alexmojaki
alexmojaki merged commit e7b52ca into main Jun 12, 2024
@alexmojaki
alexmojaki deleted the alex/no-default-auto-trace-modules branch June 12, 2024 12:32
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