wemake-python-styleguide
wemake-python-styleguide copied to clipboard
Report useless ternary operator
Rule request
Thesis
Detect if both possible results of a ternary operator return the same value.
# bad
# (all results below can be replaced by just `a`)
a if ... else a
a if a is not None else None
a if a != b else b
b if a == b else a
# ok
a if ... else c
a.split() if a is not None else None
a if a != b else c
Reasoning
It is either a bug or unnecessary complexity.
Hello word
@locko62 does it mean that you want to wrok on this issue? 🙂
Hello, I would like to work on this? This is my first-time!
@Praveenk8051 you are welcome! Please, take a look at https://github.com/wemake-services/wemake-python-styleguide/blob/master/CONTRIBUTING.md
Thank you!
Hi, I need some help. I went through documentation to know how to contribute and API References
I'm facing below error when I'm executing make test
. Can you please help me with it ? @sobolevn
I don't think i can just go ahead and install. Thanks!
I can recommend to remove your venv
, make sure that your base python
does not have any installed packages that might be causing this problem (check with pip freeze
, it should be empty), and call poetry install
once again after cleaning everything.
Worked. Thank you!
Hello, I'm trying to debug and apply changes so that linter
is applicable properly for ternary properties. But I'm failing to understand how to proceed. Can you please help me with it ? @sobolevn
This happens to be present in compares.py
where NestedTernaryViolation
is checked. Am I on right path ? Should i check and tweak in compares.py
Yes, please fix all the violations in our own source code found by a new rule!
Hello @sobolevn. I would also like to work on this issue apart from #1974 with @bhargavi247. We are students who are working on an assignment to fix Issues for open source projects. Do let us know if this issue is still open! Thank you!
Yes, it is! Thanks!
Awesome! Let us get started on this issue as well. If you could assign it to @bhargavi247 that would be great.
Thanks @sobolevn ! Would love to get assigned to this task :)
I would like to work on this issue, I am a first-time contributor Can someone guide me on how to proceed with this issue?
Hi @harshakhmk! Please, take a look at https://github.com/wemake-services/wemake-python-styleguide/blob/master/CONTRIBUTING.md
Hi! I'm fairly new to open source contribution but would like to give this issue a try. If this issue is unclaimed, could I possibly be assigned. Also, if I do need assistance, would I be able to receive guidance from other contributors in this repository?
This is hot....does anyone have the idea how to write a visitor for this
#2579
Is this issue still open? If so I would be interested in being assigned to this issue. Like many others here also new to open source and would appreciate the opportunity to learn.
@FieldMarshallObvious please, go ahead :)
you can take a look at https://github.com/wemake-services/wemake-python-styleguide/pull/2579 it was a promising start, but never fixed tests :(
Thanks! Will do 👍
Attempt to fix this on PR #2902
@FieldMarshallObvious is working on it right now, please take some other issue :) There are multiple ones that are free!
@sobolevn Can you please suggest other issues for beginners?