10000 MAINT: Removed suitable unused variables shown in LGTM by ajayd-san · Pull Request #19102 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

MAINT: Removed suitable unused variables shown in LGTM #19102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 9, 2021

Conversation

ajayd-san
Copy link
Contributor

Fixes most of the unused variable linting errors shown in LGTM.

partially closes #19077

@@ -2553,8 +2552,7 @@ def get_parameters(vars, global_params={}):
elif iscomplex(vars[n]):
# FIXME complex numbers may also have exponents
if v[0] == '(' and v[-1] == ')':
# FIXME, unused l looks like potential bug
l = markoutercomma(v[1:-1]).split('@,@')
pass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this reflect a deeper problem? Should the result of markeroutercomma be used somewhere?

I think this should be left for a future clean-up PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like an unfinished implementation. In short term, replace the block under elif iscomplex(...): with

outmess(f'get_parameters[TODO]: implement evaluation of complex expression {v}')

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is resolved.

@mattip
Copy link
Member
mattip commented May 26, 2021

Unless one of the f2py people can approve that the unused function call results are indeed not needed, I would suggest removing them for now. @pearu, @melissawm thoughts?

@ajayd-san
Copy link
Contributor Author

sure, I'll follow up with a new commit shortly.

@@ -3107,8 +3105,6 @@ def show_all(argv=None):
del show_only[show_only.index(name)]
conf = c()
conf.verbosity = 2
# FIXME: r not used
r = conf.get_info()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this has side effects based on the verbosity settings above, so the conf.get_info call is still needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, I'll reflect that change in a new commit.

Copy link
Contributor
@pearu pearu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My review covers only the crackfortran.py part.

@@ -1127,7 +1127,6 @@ def analyzeline(m, case, line):
(m.group('this'), ll[:i]))
ll = ll + ','.join(groupcache[groupcounter]['args'])
if i < 0:
i = 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is valid removal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey, I commited your reviewed changes. Can you tell if you are satisfied ?
The azure lint test seems to fail, reason being outmess(f'get_parameters[TODO]: implement evaluation of complex expression {v}'), Can you check?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a "line too long" error. You'll need to split the line, for instance:

outmess('get_parameters[TODO]:'
        f' implement evaluation of complex expression {v}')

(untested).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal looks to be gone, wasn't it valid?

@@ -2553,8 +2552,7 @@ def get_parameters(vars, global_params={}):
elif iscomplex(vars[n]):
# FIXME complex numbers may also have exponents
if v[0] == '(' and v[-1] == ')':
# FIXME, unused l looks like potential bug
l = markoutercomma(v[1:-1]).split('@,@')
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like an unfinished implementation. In short term, replace the block under elif iscomplex(...): with

outmess(f'get_parameters[TODO]: implement evaluation of complex expression {v}')

@charris
Copy link
Member
charris commented May 28, 2021

There test failure is unrelated.

# FIXME, unused l looks like potential bug
l = markoutercomma(v[1:-1]).split('@,@')
outmess(f'get_parameters[TODO]:'
f'implement evaluation of complex expression {v}')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is off, should align under first string.

@@ -3107,7 +3105,8 @@ def show_all(argv=None):
del show_only[show_only.index(name)]
conf = c()
conf.verbosity = 2
# FIXME: r not used
# we don't need the result, but we want
# the side effect of printing diagnostics
r = conf.get_info()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
r = conf.get_info()
conf.get_info()

@ajayd-san
Copy link
Contributor Author

can anyone review changes ?

if v[0] == '(' and v[-1] == ')':
# FIXME, unused l looks like potential bug
l = markoutercomma(v[1:-1]).split('@,@')
outmess(f'get_parameters[TODO]:'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
outmess(f'get_parameters[TODO]:'
outmess(f'get_parameters[TODO]: '

Else this will print TODO]:implement with no space

@@ -2985,7 +2983,7 @@ def expr2name(a, block, args=[]):

def analyzeargs(block):
setmesstext(block)
implicitrules, attrrules = buildimplicitrules(block)
implicitrules = buildimplicitrules(block)[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
implicitrules = buildimplicitrules(block)[0]
implicitrules, _ = buildimplicitrules(block)

Is probably slightly clearer

@ajayd-san
Copy link
Contributor Author
C:\hostedtoolcache\windows\Python\3.9.5\x86\lib\site-packages\numpy\core\tests\test_multiarray.py:3029: RuntimeWarning

this seems to be coming from multiarray.py but i didn't make any changes to that file.
Can anyone review ?

@charris charris mentioned this pull request Jun 25, 2021
@seberg
Copy link
Member
seberg commented Jul 8, 2021

Everything besides the f2py seems pretty simple, and I guess Pearu is happy with that. @charris happy to merge?

Copy link
Contributor
@pearu pearu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mattip mattip merged commit 1f95d79 into numpy:main Jul 9, 2021
@mattip
Copy link
Member
mattip commented Jul 9, 2021

Thanks @default-303

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LGTM alerts .
8 participants
0