question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect signature of operators

See original GitHub issue

Hello,

Currently, the signatures of most operators look similar to the following.

    @apply_defaults
    def __init__(
        self, sql: str, conn_id: Optional[str] = None, *args, **kwargs
    ) -> None:
        super().__init__(*args, **kwargs)
        self.conn_id = conn_id
        self.sql = sql

There are two problems here.

  1. The apply_default decorator forces all arguments to be passed as keyword arguments, but this information is not marked in the signature. As of Python 3 it is possible to mark arguments as keyword-only argument.
  2. The *args is passed to the BaseOperator class, but this class does not accept positional arguments.

The new operator signature may look like folllow

    @apply_defaults
    def __init__(
        self, *, sql: str, conn_id: Optional[str] = None, **kwargs
    ) -> None:
        super().__init__(**kwargs)
        self.conn_id = conn_id
        self.sql = sql

This change will allow the detection of improper operator initialization by static code analysis tools. This will also improve the operator’s documentation as the method signature is available in the Python API Reference.

This change is backward-compatible because the positional arguments were not accepted before, but this was not enforced by the Python interpreter, but by an ddecorator.

We can use Bowler to do it.

Best regards, Kamil

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
mik-lajcommented, Aug 4, 2020

@LeonY1 CLA is not required.

1reaction
mik-lajcommented, Aug 6, 2020

@LeonY1 You can start. You are already assigned to this ticket so I cannot assign you again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

C++ -- Incorrect signature for assignment operator?
Assignment meant you assign a value to something that already exists. · The assignment operator should take its argument as a const-reference: A& ......
Read more >
scheduled apex - Incorrect signature for a SchedulableContext
I'm trying to create a daily export of a .csv report on Salesforce Apex. The problem is I can't test this code beacause...
Read more >
Report warning on 'contains' function with 'operator' annotation and ...
Report warning on 'contains' function with 'operator' annotation and incorrect signature ; Project, Kotlin ; Priority, Not specified ; Type, Bug B ;...
Read more >
Method does not exist or incorrect signature: [Id].equals(String)
Hi,. I am still new to Apex, and learning more functions and expected this to work: trigger DelCustPrevent on Account (before delete) {...
Read more >
161109 - An internal error has occurred. Incorrect Operator ...
Message. An internal error has occurred. Incorrect Operator Signature. Domain, CCLScript. Code, 161109. Severity, Error.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found