MarcoGorelli / cython-lint

Lint Cython files
MIT License
68 stars 11 forks source link

Methods with same name as an import cause shadowing errors #94

Open jonathanhogg opened 6 months ago

jonathanhogg commented 6 months ago

If I use a method name that matches a name that has been imported, I get "shadows global import" errors from cython-lint. Maybe this is just me, but I don't see this as unusual practice.

Simple failing example:

from libc.math cimport floor

cdef class Foo:
    cdef double f

    def __init__(self, f):
        self.f = f

    cpdef Foo floor(self):
        return Foo(floor(self.f))

    def __repr__(self):
        return f'Foo({self.f})'
MarcoGorelli commented 6 months ago

thanks for the issue - interested in submitting a fix?

jonathanhogg commented 6 months ago

You know, I did take a look at the code but I was in a hurry and wanted to get the issue logged before thinking about it harder.

I'm pretty busy but will have a play and see if I can make sense of it… 🧐

MarcoGorelli commented 6 months ago

thanks! I have very little time for this too at the moment unfortunately, but would happily review a PR

else I'll get to it when I have a chance, at the moment I have quite a few high-priority things on my plate I'm afraid