spikeinterface icon indicating copy to clipboard operation
spikeinterface copied to clipboard

Import style in code-base

Open alejoe91 opened this issue 1 year ago • 7 comments

Hi guys,

I think we should unify the way we import internal functions across the code-base.

Currently we have a lot of relative imports + some full imports in the source code. Od course tests should keep full imports.

All in favor?

@samuelgarcia @h-mayorquin @zm711 @chrishalcrow @JoeZiminski @yger

alejoe91 avatar Jun 13 '24 12:06 alejoe91

Agreed! I was swayed to use full imports in another package by this top answer. This can also be linted in ruff for enforcement if desired.

JoeZiminski avatar Jun 13 '24 12:06 JoeZiminski

Interesting! yeah maybe then we should just switch to absolute imports. Anyone has strong feelings about this?

alejoe91 avatar Jun 13 '24 13:06 alejoe91

@alejoe91 are you proposing to make all imports full imports in the code base?

I personally prefer absolute imports as well. We use relative imports in neuroconv and I often find myself wondering what is the location of some something and that is occluded by the dots (e.g. I don't know where ..a_module is).

The only advantage that I see of relative imports is that module re-organization might be easier but my IDE takes care of that problem for me if it ever arises (and it should arise very seldom!).

h-mayorquin avatar Jun 13 '24 14:06 h-mayorquin

I'm proposing to unify imports! If you guys think that absolute are better, let's go for it!

alejoe91 avatar Jun 13 '24 14:06 alejoe91

Ah, got you, thanks, yeah, I prefer absolute imports (and that would be less work, I feel, right?).

h-mayorquin avatar Jun 13 '24 14:06 h-mayorquin

I prefer relative :) of course.

samuelgarcia avatar Jun 14 '24 09:06 samuelgarcia

Just got back from vacation :)

I think from bring in new people perspective absolute is the way to go. It gives provenance (which we all love). I like the look of relative better, but I think we want to be as inclusive as possible for people so new folks can easily navigate the code base :)

zm711 avatar Jun 17 '24 12:06 zm711

Well are we good on this or is there more debate? Basically we all agreed to absolute except Sam and then we never did anything :) haha.

zm711 avatar Feb 05 '25 22:02 zm711

Now that I've been coding a bit longer, I can vote! Also pro absolute imports, and am using them in other projects I'm working on.

chrishalcrow avatar Feb 06 '25 08:02 chrishalcrow

Ok the Parliament has spoken! @chrishalcrow does this classify as one of your bori..exciting tasks you could take on as a new year's resolution? :)

alejoe91 avatar Feb 06 '25 09:02 alejoe91

Done in #3766

chrishalcrow avatar Mar 13 '25 10:03 chrishalcrow