Giter Site home page Giter Site logo

Comments (9)

hbrunn avatar hbrunn commented on June 9, 2024

I think something like

try:
    from oca.decorators import foreach
except ImportError:
    foreach = lambda x: x

could do the trick. For every decorator we import, we declare it to be the identity function if the import fails. Then we don't need the ugly catch all import.

from oca-decorators.

yajo avatar yajo commented on June 9, 2024

I think that is a good workaround, although it should violate some pylint/flake8 too. By adding a # noqa to the except it should be OK.

from oca-decorators.

yajo avatar yajo commented on June 9, 2024

However, there's a problem here that we've been struggling all the life: why in the world do we need to fake a requirement? If the addon is not installed and it produces an ImportError... why should Odoo care at all? It's what should happen, because there's actually an import error! We should fix Odoo I think.

from oca-decorators.

legalsylvain avatar legalsylvain commented on June 9, 2024

Thanks a lot @hbrunn. I think we should add an help in the documentation of this library.

We should fix Odoo I think.

@yajo : 100% agree with you, but an other (big) story I think.

from oca-decorators.

yajo avatar yajo commented on June 9, 2024

Cool, it seems we're just late to the party.

The fix landed in master some months ago.

I think we could backport it to OCB and merge OCA/pylint-odoo#182 once for all and just stop supporting this precise kind of fixes for non OCB builds.

Would you agree?
cc @pedrobaeza

from oca-decorators.

pedrobaeza avatar pedrobaeza commented on June 9, 2024

Well, as we need to keep the tricks for Odoo part, it's not worth to backport it.

from oca-decorators.

yajo avatar yajo commented on June 9, 2024

I was talking about providing different kind of fixes:

  • if you use OCB, it's fixed out of the box.
  • if you use odoo, the fix is to add the dependency.

So both versions are "supported" but we don't care anymore about this.

from oca-decorators.

hparfr avatar hparfr commented on June 9, 2024

I was talking about providing different kind of fixes:
if you use OCB, it's fixed out of the box.
if you use odoo, the fix is to add the dependency.
So both versions are "supported" but we don't care anymore about this.

LGTM 👍

from oca-decorators.

yajo avatar yajo commented on June 9, 2024

I'm thinking that there's a still easier solution:

  1. in versions < 12.0, use @api.one
  2. in versions >= 12.0 (when available), use this lib in OCA freely.

from oca-decorators.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.