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

False positive with mypy #305

Open
Franco0700 opened this issue Feb 14, 2023 · 1 comment
Open

False positive with mypy #305

Franco0700 opened this issue Feb 14, 2023 · 1 comment

Comments

@Franco0700
Copy link

Defining a customFunctions, like this:

class CustomFunctions(jmespath.functions.Functions):
        @jmespath.functions.signature({'types': ['object']}, {'types': ['array']})
        def _func_map_merge(self, obj: str, arg: list[dict[str, str]]) -> list[dict[str, str]]:
            result = []
            for element in arg:
                merged_object = super()._func_merge(obj, element)
                result.append(merged_object)
            return result

Drop the following error

error: "_func_merge" undefined in superclass

I think it should be some missing information on stubs

@Franco0700 Franco0700 changed the title Fake positive with mypy False positive with mypy Feb 14, 2023
@jamesls
Copy link
Member

jamesls commented Mar 31, 2023

I'm not able to repro, can you give me the entire script as well as the commands you're running? Here's what I tried:

import jmespath
from jmespath import functions
from typing import List, Dict


class CustomFunctions(functions.Functions):
    @functions.signature({'types': ['object']}, {'types': ['array']})
    def _func_map_merge(self, obj: str, arg: List[Dict[str, str]]) -> List[Dict[str, str]]:
        result = []
        for element in arg:
            merged_object = super()._func_merge(obj, element)
            result.append(merged_object)
        return result


options = jmespath.Options(custom_functions=CustomFunctions())
$ mypy check.py
Success: no issues found in 1 source file

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