Skip to content

Fixed #2127 - WPS000 on several code fragments (Fragment 1)#2131

Merged
sobolevn merged 6 commits intomasterfrom
unknown repository
Aug 21, 2021
Merged

Fixed #2127 - WPS000 on several code fragments (Fragment 1)#2131
sobolevn merged 6 commits intomasterfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Aug 7, 2021

I have made things!

Checklist

  • I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
  • I have created at least one test case for the changes I have made
  • I have updated the documentation for the changes I have made
  • I have added my changes to the CHANGELOG.md

Related issues

🙏 Please, if you or your company is finding wemake-python-styleguide valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/wemake-python-styleguide. As a thank you, your profile/company logo will be added to our main README which receives hundreds of unique visitors per day.

@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 7, 2021

This is my first ever pull request, so please let me know if I'm doing something wrong. I identified the cause of the first fragment of issue #2127 and proposed a solution.

I tried creating a regression test, but not sure I did it correctly. Any advice or somewhere I can look at documentation would be appreciated!

Copy link
Copy Markdown
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

You are doing great! Congrats on your first PR 🎉

Now CI will suggest some small nitpicks to fix before your PR can be merged, please, address the highlighted issues. And I will be happy to merge it!

@sobolevn
Copy link
Copy Markdown
Member

sobolevn commented Aug 7, 2021

You can also run flake8 . locally to find the problems.

@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 7, 2021

Thanks @sobolevn! I appreciate it.

I think I fixed all the highlighted issues.

Copy link
Copy Markdown
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Awesome, thank you!

@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 7, 2021

Thanks, so much @sobolevn. Is there anything else I need to do on my end for this issue?

@sobolevn
Copy link
Copy Markdown
Member

sobolevn commented Aug 8, 2021

Yes, there are three failing tests. We need to figure out what to do with them.

Copy link
Copy Markdown
Author

@ghost ghost left a comment

Choose a reason for hiding this comment

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

@sobolevn Whenever you have some time, could you take a look at this? I think this is part of why the errors are happening.



def test_regression2127(
assert_errors,
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It looks like the test is failing here. assert_errors is not a part of the pytest --fixtures list. But looking at other tests, it looks like that is used to assert whether any errors are occurring on a visitor. I tired to use the same method here, but it seems like it can't find assert_errors. Any idea what I'm missing here?

Copy link
Copy Markdown
Member

@sobolevn sobolevn Aug 9, 2021

Choose a reason for hiding this comment

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

Yes, assert_errors is defined in tests/test_visitors.py: https://github.com/wemake-services/wemake-python-styleguide/blob/master/tests/test_visitors/conftest.py#L20

Move your tests into tests/test_visitors subfolder and it should be fine! 👍

@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 11, 2021

@sobolevn Sorry to keep bothering you, but I can't seem to figure out what's going wrong with the test. I tried a few different things, but nothing seems to be working.

It looks like the issue is in the test_no_qa.py file. Any insight on where I should investigate as to why the tests are failing?

@sobolevn
Copy link
Copy Markdown
Member

Hey! There are also style issues:

Raw Output:
./tests/test_visitors/test_if_else_one_line.py:2:1: I005 isort found an unexpected missing import
./tests/test_visitors/test_if_else_one_line.py:1:1: I001 isort found an import in the wrong position
./tests/test_visitors/test_if_else_one_line.py:1:81: E501 line too long (81 > 80 characters)
./tests/test_visitors/test_if_else_one_line.py:2:1: I005 isort found an unexpected missing import
./tests/test_visitors/test_if_else_one_line.py:2:1: I005 isort found an unexpected missing import
./tests/test_visitors/test_if_else_one_line.py:2:1: I005 isort found an unexpected missing import
=================================

./tests/test_visitors/test_if_else_one_line.py:1:1: F401 'wemake_python_styleguide.violations.refactoring.ImplicitElifViolation' imported but unused
./tests/test_visitors/test_if_else_one_line.py:1:1: I001 isort found an import in the wrong position
./tests/test_visitors/test_if_else_one_line.py:1:81: E501 line too long (81 > 80 characters)
./tests/test_visitors/test_if_else_one_line.py:2:1: I005 isort found an unexpected missing import
./tests/test_visitors/test_if_else_one_line.py:2:1: I005 isort found an unexpected missing import
./tests/test_visitors/test_if_else_one_line.py:2:1: I005 isort found an unexpected missing import
Process failed with the status code: 1

Let's fix them first, so we can actually see failing tests output.

@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 12, 2021

Apologies. I fixed the style issues and ran flake8 and mypy locally with no issues, so hopefully that gets all of the style issues.

@sobolevn
Copy link
Copy Markdown
Member

@ghost
Copy link
Copy Markdown
Author

ghost commented Aug 12, 2021

Thanks for that @sobolevn. That was super helpful in terms of helping me understand what was going on. I think I fixed the issue and passed all tests this time around.

@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 21, 2021

Codecov Report

Merging #2131 (22ee7d8) into master (e70019e) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #2131   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          118       118           
  Lines         6207      6213    +6     
  Branches      1379      1379           
=========================================
+ Hits          6207      6213    +6     
Impacted Files Coverage Δ
..._python_styleguide/visitors/tokenize/conditions.py 100.00% <100.00%> (ø)
wemake_python_styleguide/logic/tree/keywords.py 100.00% <0.00%> (ø)
...emake_python_styleguide/visitors/ast/conditions.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 46cbdd7...22ee7d8. Read the comment docs.

@sobolevn sobolevn merged commit c7c77b7 into wemake-services:master Aug 21, 2021
@sobolevn
Copy link
Copy Markdown
Member

@danielboghean thanks again! 👍

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants