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.

Require parameters to be passed as keyword arguments for long funciton signatures.

See original GitHub issue

What is wrong?

There are lots of places in the codebase with either classes or functions which take 6+ parameters. In these cases, calling these using positional arguments can be both error prone as well as hard to read.

  • Errors arise when arguments are accidentally called in the wrong order.
  • Difficult readability comes when it’s not clear what each parameter actually means since sometimes multiple parameters might be called with the same constant value f(b'', b'').

How can it be fixed

https://www.python.org/dev/peps/pep-3102/

PEP3102 introduces a new syntax for requiring certain arguments to be called as keyword arguments. I propose changing as many of the functions as seems appropriate to this format.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
palash25commented, Apr 13, 2018

This is what I got from a git grep. I didn’t find 7 but only six functions with 6 or more arguments

evm/vm/logic/call.py
272:def compute_eip150_msg_gas(computation, gas, extra_gas, value, mnemonic, callstipend):

tests/trinity/json-fixtures-over-rpc/test_rpc_fixtures.py
131:def validate_account_attribute(fixture_key, rpc_method, rpc, state, addr, at_block):

evm/vm/forks/byzantium/transactions.py
13:    def create_unsigned_transaction(cls, nonce, gas_price, gas, to, value, data):

evm/vm/forks/frontier/transactions.py
79:    def create_unsigned_transaction(cls, nonce, gas_price, gas, to, value, data):

evm/vm/forks/homestead/transactions.py
43:    def create_unsigned_transaction(cls, nonce, gas_price, gas, to, value, data):

evm/vm/forks/spurious_dragon/transactions.py
35:    def create_unsigned_transaction(cls, nonce, gas_price, gas, to, value, data):

Are these the functions that you had in mind @pipermerriam ? Can I work on this?

0reactions
pipermerriamcommented, Oct 8, 2018

closed by #1368

Read more comments on GitHub >

github_iconTop Results From Across the Web

Four Types of Parameters and Two Types of Arguments in ...
We can use all 4 types of parameters in one function. Of course, there are some enforced rules. Since the keyword variable-length parameter...
Read more >
Using Python Optional Arguments When Defining Functions
You can also pass required and optional arguments into a function as keyword arguments. Keyword arguments can also be referred to as named...
Read more >
Code Style - The Hitchhiker's Guide to Python - Read the Docs
When a function has more than two or three positional parameters, its signature is more difficult to remember and using keyword arguments with...
Read more >
Forced naming of parameters in Python - Stack Overflow
Parameters after “*” or “*identifier” are keyword-only parameters and may only be passed used keyword arguments. >>> def foo(pos, *, forcenamed): ... print ......
Read more >
5 Types of Arguments in Python Function Definitions
Actual parameters(arguments) are passed during a function call. ... Functions can also be called using keyword arguments of the form ...
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