django-rest-framework-bulk icon indicating copy to clipboard operation
django-rest-framework-bulk copied to clipboard

try/except/pass in __init__.py

Open GertBurger opened this issue 9 years ago • 3 comments

Hi

Is this necessary?

I recently ran into a circular import issue where drf-bulk imports drf which in turn imports some of our code(via DEFAULT_PAGINATION_CLASS in DRF) and it hid the actual error which occurred deep inside our code.

GertBurger avatar Feb 10 '16 12:02 GertBurger

the original intention is to be able to import useful modules directly from the package:

from rest_framework_bulk import ....

its not strictly necessary however I think it does not hurt. Not sure however about masking other exceptions. Can you give an example? If its a common error people can get, I could remove the try..except.

miki725 avatar Feb 10 '16 15:02 miki725

Any idea why this package would be catching syntax errors in other files?

waltz avatar Nov 17 '17 18:11 waltz

The steps are as follows:

  1. Your code imports rest_framework_bulk
  2. rest_framework_bulk imports DRF
  3. DRF can import some other parts of your code as specified by DEFAULT_PAGINATION_CLASS in the django setttings module.

This assumes that DRF(and replacement classes) have not been fully imported before rest_framework_bulk gets imported.

If during step 3, where DRF imports your code, there is any error it will be hidden due to the blanket exception handling in __init.py__

GertBurger avatar Nov 20 '17 08:11 GertBurger