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

Sidekiq 7.0 incompatible with current sidekiq annotations #124

Open
leifg opened this issue Nov 2, 2022 · 1 comment
Open

Sidekiq 7.0 incompatible with current sidekiq annotations #124

leifg opened this issue Nov 2, 2022 · 1 comment
Labels
bug Something isn't working rbi Change related to RBI annotations

Comments

@leifg
Copy link
Contributor

leifg commented Nov 2, 2022

Problem

When running type on a project that uses the latest sidekiq version, I will get this type error:

sorbet/rbi/gems/[email protected]:2965: Cannot initialize the module Worker by constant assignment https://srb.help/4022
    2965 |Sidekiq::Worker = Sidekiq::Job
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    sorbet/rbi/annotations/sidekiq.rbi:79: Previously defined as a module here
    79 |module Sidekiq::Worker
        ^^^^^^^^^^^^^^^^^^^^^^
  Note:
    Sorbet does not allow treating constant assignments as class or module definitions,
    even if the initializer computes a Module object at runtime. See the docs for more.

At first glance this doesn't seem to an issue of annotations, but changing all references of Sidekiq::Worker to Sidekiq::Job in sorbet/rbi/annotations/sidekiq.rbi fixes the issue.

Weirdly enough, when changing the references in a project that uses sidekiq < 7.0.0 also causes an error:

Method sidekiq_options does not exist on T.class_of(MyJob) https://srb.help/7003

Seems like a good use case for versioning

Context

I'm using include Sidekiq::Job in all my workers (in 6.0. and 7.0)

Sidekiq aliases Sidekiq::Job to Sidekiq::Worker. Weirdly enough this has not been introduced in 7.0 and has been there before.

  • Gem name: sidekiq
  • Gem version: 7.0.0
  • Tapioca version: 0.10.2
  • Sorbet version: 0.5.10517
@leifg leifg changed the title Sidekiq 7.0 causes Sidekiq 7.0 incompatible with current sidekiq annotations Nov 2, 2022
@KaanOzkan
Copy link
Contributor

This is probably new because of a Sorbet a upgrade. It's better to support latest versions so feel free to open a PR that changes the annotation to use Job. It's encouraged in https://github.com/mperham/sidekiq/blob/636fa9a06a50e2437d91fa21be64a9bf233369c7/lib/sidekiq/worker_compatibility_alias.rb#L4-L11

@leifg leifg mentioned this issue Nov 4, 2022
3 tasks
@Morriar Morriar added bug Something isn't working rbi Change related to RBI annotations labels Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rbi Change related to RBI annotations
Projects
None yet
Development

No branches or pull requests

3 participants