-
-
Notifications
You must be signed in to change notification settings - Fork 74
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
refactor: Change linting to Ruff #978
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #978 +/- ##
==========================================
+ Coverage 87.24% 87.31% +0.07%
==========================================
Files 9 9
Lines 4948 4944 -4
==========================================
Hits 4317 4317
+ Misses 631 627 -4 ☔ View full report in Codecov by Sentry. |
param/parameterized.py
Outdated
@@ -26,7 +26,7 @@ | |||
# Allow this file to be used standalone if desired, albeit without JSON serialization | |||
try: | |||
from . import serializer | |||
except ImportError: | |||
except ModuleNotFoundError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure about this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested it. Needs to be an ImportError
except ModuleNotFoundError: | |
except ImportError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though even with ImportError it still does not work...
❯ python -c "import param" # with ModuleNotFoundError
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/shh/projects/holoviz/repos/param/param/__init__.py", line 4, in <module>
from .depends import depends # noqa: api import
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/projects/holoviz/repos/param/param/depends.py", line 9, in <module>
from .parameterized import (
File "/home/shh/projects/holoviz/repos/param/param/parameterized.py", line 28, in <module>
from . import serializer
ImportError: cannot import name 'serializer' from partially initialized module 'param' (most likely due to a circular import) (/home/shh/projects/holoviz/repos/param/param/__init__.py)
param on refactor_ruff [$✘] via 🅒 holoviz
❯ python -c "import param" # with ImportError
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/shh/projects/holoviz/repos/param/param/__init__.py", line 4, in <module>
from .depends import depends # noqa: api import
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/shh/projects/holoviz/repos/param/param/depends.py", line 9, in <module>
from .parameterized import (
File "/home/shh/projects/holoviz/repos/param/param/parameterized.py", line 1027, in <module>
class Parameter(_ParameterBase):
File "/home/shh/projects/holoviz/repos/param/param/parameterized.py", line 1170, in Parameter
_serializers = {'json': serializer.JSONSerialization}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'JSONSerialization'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove the try/except here? Nobody has complained about it, and that line was changed in June of 2021.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I've heard, and IIRC, Param was designed to be used super easily by simply copy-pasting one or two files in a project, which works as it has no external dependency. It's likely it made people's lives easier 10/15 years ago, these days we expect users to pip/conda install
their dependencies and in the vast majority of cases it works fine.
So I think that yes we should remove the try/except
and generally lift the assumption that you can copy-paste some modules and it works, if it's baked in other places. I also wouldn't be surprised if one day we added some dependencies to Param (e.g. typing-extensions
if we finally do some typing work in Param).
Aligning with our other repos.