spinlud / py-linkedin-jobs-scraper

MIT License
337 stars 95 forks source link

Refactored callback validation to use callable() for broader compatibility. #78

Open daniilpastukhov opened 8 months ago

daniilpastukhov commented 8 months ago

At the moment, LinkedinScraper.on method doesn't allow class methods to be passed as a callback. Example:

class A:
    def __init__(self):
        self.scraper = LinkedinScraper(...)
        self.scraper.on(..., self.callback)

     def callback(self):
          ...

This code fails with ValueError: Callback must be a function.

This PR proposes utilising Python's callable method instead of checking whether callback is an instance of FunctionType.

J3rome commented 1 month ago

I've made a similar change on my side. Would love to see this merged.