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

content_type/2 spec annotation incorrect #183

Open
rmbenham opened this issue Feb 3, 2025 · 1 comment
Open

content_type/2 spec annotation incorrect #183

rmbenham opened this issue Feb 3, 2025 · 1 comment

Comments

@rmbenham
Copy link

rmbenham commented Feb 3, 2025

Hi all,

A super nitpicky and minor issue I am having that I hope can be addressed down the line in a future version (or hopefully this serves to be useful to someone else): I am doing a pass over my codebase using Dialyxir and I noticed that for this library many of the example usages of Contentful.Delivery.Entries involve a pattern of passing Entries through to functions:

Entries |> fetch_all

However, when I use content_type with Entries supplied as the first argument I get type errors.

Entries |> content_type("hello") |> fetch_all

I know from inspecting the library code that calling the function in this way is implemented and actually supported so is not causing any actual implementation errors, but I'd like to ignore the error as a last resort. I am not sure how pervasive this @spec issue is for other functions within the library, but the workaround I have is to supply {Entries, []} as is done internally as it is captured by the current @spec annotation:

#  @spec content_type({Entries, list()}, String.t() | ContentType.t()) :: {Entries, list()} | any()
{Entries, []} |> content_type("hello") |> fetch_all

Adding | Entries to the typespec in the library would likely resolve the issue

 @spec content_type({Entries, list()} | Entries, String.t() | ContentType.t()) :: {Entries, list()} | any()

but not sure whether it would be helpful to run mix dialyzer to capture any other errors in the same foray.

@floriank
Copy link
Collaborator

floriank commented Feb 3, 2025

Nitpicky issues ?!

Sign me up, I'll happy to accept a PR for this <3

thanks for investigating 👍

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

No branches or pull requests

2 participants