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

pure_interface.mypy_plugin [no-redef] error using Delegate #107

Open
XavierMilesSeequent opened this issue May 6, 2024 · 0 comments
Open
Assignees

Comments

@XavierMilesSeequent
Copy link
Contributor

The plugin does not check for existing definitions when adding methods for pi_attr_delegates. So if the method is defined on the interface, then it will be defined twice, causing a [no-redef] mypy error.

This is the basic setup that I believe should reproduce it. I don't know why the error isn't occurring outside of leapfrog though, so maybe check against modflow_usg.py itself.

import pure_interface


class TwoDUnstructuredModFlowGridBlock:
    def get_voronoi_centres_loader(self):
        return 'Hello'


class IExportableModflowUSGrid(pure_interface.Interface):
    def get_voronoi_centres_loader(self):
        pass


class UnstructuredModFlowGridBlock:
    def __init__(self) -> None:
        self.two_d_grid = TwoDUnstructuredModFlowGridBlock()


@pure_interface.adapts(UnstructuredModFlowGridBlock)
class ExportableUSGrid(pure_interface.Delegate, IExportableModflowUSGrid):
    pi_attr_fallback = 'mf_grid'
    pi_attr_delegates = {
        'two_d_grid': ['get_voronoi_centres_loader']
    }

    def __init__(self, mf_grid: UnstructuredModFlowGridBlock):
        self.mf_grid = mf_grid
        self.two_d_grid = mf_grid.two_d_grid
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