Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn off typechecking when called from exe #295

Merged
merged 3 commits into from
Jan 6, 2023
Merged

Turn off typechecking when called from exe #295

merged 3 commits into from
Jan 6, 2023

Conversation

gmcgibbon
Copy link
Member

@gmcgibbon gmcgibbon commented Jan 6, 2023

What are you trying to accomplish?

Some better typing, followed by disabling Sorbet when called from the executable / spring command.

What approach did you choose and why?

Type checking is useful, but I don't see use for it to be enabled in "production" use of the gem. When packwerk is validating or checking a codebase, type checking just slows it down and provides unhelpful errors to the user when something internal fails.

What should reviewers focus on?

Here's some benchmarks to compare runs on a huge app. I think this makes packwerk 20% faster.

  • This branch
    • bundle exec packwerk check 79.08s user 23.77s system 298% cpu 34.415 total
    • bundle exec packwerk check 973.03s user 30.03s system 624% cpu 2:40.58 total (uncached)
  • Main
    • bundle exec packwerk check 104.68s user 24.02s system 226% cpu 56.929 total
    • bundle exec packwerk check 1380.94s user 33.25s system 634% cpu 3:43.04 total (uncached)

Type of Change

  • Bugfix
  • New feature
  • Non-breaking change (a change that doesn't alter functionality - i.e., code refactor, configs, etc.)

Additional Release Notes

  • Breaking change (fix or feature that would cause existing functionality to change)

Include any notes here to include in the release description. For example, if you selected "breaking change" above, leave notes on how users can transition to this version.

If no additional notes are necessary, delete this section or leave it unchanged.

Checklist

  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • It is safe to rollback this change.

@gmcgibbon gmcgibbon marked this pull request as ready for review January 6, 2023 07:39
@gmcgibbon gmcgibbon requested a review from a team as a code owner January 6, 2023 07:39

T::Configuration.default_checked_level = :never

T.singleton_class.prepend(
Copy link
Contributor

Choose a reason for hiding this comment

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

I just wish Sorbet had better support for turning off runtime type checking in production.

My ideal would be that you could use extend S::Sig (S for Static) which would add sigs that have no runtime component, and then in a test suite you could turn on runtime type checking. Stripe folks feel pretty strongly that runtime checking shouldn't be disabled though so I don't think it will happen.

@gmcgibbon gmcgibbon merged commit ffa099f into main Jan 6, 2023
@gmcgibbon gmcgibbon deleted the turn_off_tc branch January 6, 2023 21:26
@shopify-shipit shopify-shipit bot temporarily deployed to rubygems March 1, 2023 19:58 Inactive
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.

None yet

2 participants