Skip to content

Commit

Permalink
Separate dev cruft from code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzohrab committed Jan 17, 2025
1 parent 88e3449 commit 0eaf22d
Showing 1 changed file with 31 additions and 36 deletions.
67 changes: 31 additions & 36 deletions pylint/checkers/typecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -1454,18 +1454,6 @@ def visit_call(self, node: nodes.Call) -> None:
and that passed arguments match the parameters in the inferred function.
"""

def _dp(s, val=None):
return
## if "Attribute.__init__" not in str(node):
## return
## if val is None:
## print(f" {s}", flush=True)
## else:
## print(f" {s}: {val}", flush=True)

_dp("-" * 25)
_dp("visit call, node", node)

called = safe_infer(node.func, compare_constructors=True)
self._check_not_callable(node, called)
try:
Expand All @@ -1475,27 +1463,38 @@ def _dp(s, val=None):
# those errors are handled by different warnings.
return

_dp("Data dump for __init__ call")
# Build the set of keyword arguments, checking for duplicate keywords,
# and count the positional arguments.
call_site = astroid.arguments.CallSite.from_call(node)
_dp("call_site", call_site)
# _dp("call_site args", call_site.arguments)
# _dp("call site positional args:", call_site.positional_arguments)
# _dp("call site keyword args:", call_site.keyword_arguments)
# _dp("call site invalid args", call_site.has_invalid_arguments())
# _dp("call site inv keywords", call_site.has_invalid_keywords())
_dp("node args", node.args)
_dp("node frame", node.frame())
# _dp("isinst", isinstance(node.frame(), nodes.ClassDef))
# _dp("funcdef", isinstance(called, nodes.FunctionDef))
_dp("called", called)
_dp(
"bound method init in called",
"BoundMethod __init__ of builtins.object" in str(called),
)
_dp("called.args", called.args)
_dp("frame body", node.frame().body)
# _dp("called in frame body", called in node.frame().body)
# _dp("dec names", called.decoratornames())

### Debug cruft used during dev, will remove when done.
### def _dp(s, val=None):
### return
### ## if "Attribute.__init__" not in str(node):
### ## return
### ## if val is None:
### ## print(f" {s}", flush=True)
### ## else:
### ## print(f" {s}: {val}", flush=True)
### _dp("-" * 25)
### _dp("visit call, node", node)
### _dp("Data dump for __init__ call")
### _dp("call_site", call_site)
### _dp("call_site args", call_site.arguments)
### _dp("call site positional args:", call_site.positional_arguments)
### _dp("call site keyword args:", call_site.keyword_arguments)
### _dp("call site invalid args", call_site.has_invalid_arguments())
### _dp("call site inv keywords", call_site.has_invalid_keywords())
### _dp("node args", node.args)
### _dp("node frame", node.frame())
### _dp("isinst", isinstance(node.frame(), nodes.ClassDef))
### _dp("funcdef", isinstance(called, nodes.FunctionDef))
### _dp("called", called)
### _dp("bound method init in called", "BoundMethod __init__ of builtins.object" in str(called))
### _dp("called.args", called.args)
### _dp("frame body", node.frame().body)
### _dp("called in frame body", called in node.frame().body)
### _dp("dec names", called.decoratornames())

def _call_site_has_args(cs):
"""True if any args passed."""
Expand Down Expand Up @@ -1527,10 +1526,6 @@ def _call_site_has_args(cs):
# make sense of the function call in this case, so just return.
return

# Build the set of keyword arguments, checking for duplicate keywords,
# and count the positional arguments.
call_site = astroid.arguments.CallSite.from_call(node)

# Warn about duplicated keyword arguments, such as `f=24, **{'f': 24}`
for keyword in call_site.duplicated_keywords:
self.add_message("repeated-keyword", node=node, args=(keyword,))
Expand Down

0 comments on commit 0eaf22d

Please sign in to comment.