Skip to content

Conversation

@alexprabhat99
Copy link
Contributor

@alexprabhat99 alexprabhat99 commented Feb 8, 2025

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

Closes #10217

@jacobtylerwalls jacobtylerwalls added this to the 4.0.0 milestone Feb 8, 2025
@jacobtylerwalls jacobtylerwalls added the False Negative πŸ¦‹ No message is emitted but something is wrong with the code label Feb 8, 2025
@jacobtylerwalls
Copy link
Member

Thanks for pitching in with this one. There are a couple test failures to look into. We will also want a simple addition to the functional test in unidiomatic_typecheck.py. There's details in the contributor docs, but for a small change like this one you should be able to just blend your changes in without much hassle. Thanks again.

@jacobtylerwalls

This comment was marked as resolved.

@codecov
Copy link

codecov bot commented Feb 9, 2025

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 95.84%. Comparing base (12a8747) to head (d62a636).
Report is 123 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #10225   +/-   ##
=======================================
  Coverage   95.84%   95.84%           
=======================================
  Files         175      175           
  Lines       19056    19058    +2     
=======================================
+ Hits        18264    18266    +2     
  Misses        792      792           
Files with missing lines Coverage Ξ”
pylint/checkers/base/comparison_checker.py 100.00% <100.00%> (ΓΈ)
πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

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

Looks great already ! I have a question :)

left = node.left
if _is_one_arg_pos_call(left):
self._check_type_x_is_y(node, left, operator, right)
elif isinstance(left, nodes.Name) and _is_one_arg_pos_call(right):
Copy link
Member

Choose a reason for hiding this comment

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

If I understand correctly the first condition is to avoid to analyse thing like "X" is type(...), right ? Why is this a problem ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some tests were failing without this condition. So, I have added it.

Copy link
Member

Choose a reason for hiding this comment

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

Ok ! I think the check still make sense in this case so it's better to disable unidiomatic-typecheck in the affected functional tests (add a disable comment at the top of the file, or preferably on an existing line so not everything is modified in the expected output), or add the new expected message on the affected line with # [unidiomatic-typecheck]. The functional test are not very independent this kind of things happen when we fix a false negative or introduce a new check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All tests run fine now. So, I think it is better not to touch the functional tests even to disable unidiomatic-typecheck.

Copy link
Member

Choose a reason for hiding this comment

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

If I understand correctly the first condition is to avoid to analyse thing like "X" is type(...), right ?

I think it's not just string literals but almost any ast node. I think there's value in keeping this bugfix scoped small, esp as a "good first issue", but that's my 2c.

For string literals, I guess I'd expect any usage of is to have a lint warning, to resemble the runtime warning you get from python:

SyntaxWarning: "is" with 'str' literal.

@jacobtylerwalls
Copy link
Member

Thanks for the first contribution, welcome aboard!

@jacobtylerwalls jacobtylerwalls merged commit a475485 into pylint-dev:main Feb 10, 2025
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

False Negative πŸ¦‹ No message is emitted but something is wrong with the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unidiomatic-typecheck only checks left-hand side

4 participants