MulensModel icon indicating copy to clipboard operation
MulensModel copied to clipboard

Remove "import *"

Open rpoleski opened this issue 2 years ago • 7 comments

It's a bad practice to do "import *" in python. It can be replaced using specific imports or using __all__ in imported files. We should remove "import *" from __init__.py and mulensobjects/__init__.py.

rpoleski avatar Dec 12 '22 14:12 rpoleski

I'm unassigning myself, because I don't know how to fix this.

jenniferyee avatar Feb 16 '23 15:02 jenniferyee

I'm trying to remove import * commands in the import_no_star branch. @justi @ketozhang Could you please have a look and let me know if I'm not introducing any bugs in this way?

rpoleski avatar Oct 07 '23 20:10 rpoleski

I've skimmed through it and ran the repository through the ruff linter.

Looks good to me.

ketozhang avatar Oct 07 '23 20:10 ketozhang

@rpoleski I see that you started doing it in a specific branch. Currently, there are import * left only in __init__.py and mulensobjects/__init__.py? Should I keep using your branch then?

rapoliveira avatar Apr 22 '24 13:04 rapoliveira

Dear @ketozhang, I've already forgotten about this discussion and branch linked above. There are multiple similar changes like: from MulensModel.binarylens import BinaryLens -> from .binarylens import BinaryLens Is there any preference for either of them?

rpoleski avatar Apr 22 '24 18:04 rpoleski

No, not if the file using the import statement lives inside the package.

It's a stylistic preference (despite the misunderstood caution to avoid it)

ketozhang avatar Apr 22 '24 18:04 ketozhang

Thanks. In that case, @rapoliveira please make a new branch and correct __init__.py and mulensobjects/__init__.py there. Branch import_no_star will be deleted.

rpoleski avatar Apr 22 '24 18:04 rpoleski