Skip to content
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

flake8 #195

Merged
merged 17 commits into from
Oct 19, 2021
Merged

flake8 #195

merged 17 commits into from
Oct 19, 2021

Conversation

jyooru
Copy link
Contributor

@jyooru jyooru commented Oct 9, 2021

⚠ Pull Requests not made with this template will be automatically closed 🔥

Prerequisites

Why do we need this pull request?

flake8 enforces style consistency across Python projects.

The --select option in flake8 disables all other linting errors. Removing this option shows some areas of the code that could use some improvement.

A better way to ignore errors is to put them in a configuration file so that running flake8 on a local machine also ignores the same errors.

What GitHub issues does this fix?

None

Copy / paste of output

Please copy and paste the output of PyWhat with your new addition using an example that tests this addition below:

./tests/test_regex_identifier.py:30:89: E501 line too long (124 > 88 characters)
./tests/test_regex_identifier.py:39:89: E501 line too long (121 > 88 characters)
./tests/test_regex_identifier.py:46:89: E501 line too long (163 > 88 characters)
./tests/test_regex_identifier.py:58:89: E501 line too long (137 > 88 characters)
./tests/test_regex_identifier.py:102:89: E501 line too long (91 > 88 characters)
./tests/test_regex_identifier.py:257:89: E501 line too long (109 > 88 characters)
./tests/test_regex_identifier.py:490:89: E501 line too long (169 > 88 characters)
./tests/test_regex_identifier.py:573:89: E501 line too long (758 > 88 characters)
./tests/test_regex_identifier.py:583:89: E501 line too long (1662 > 88 characters)
./tests/test_regex_identifier.py:592:89: E501 line too long (1210 > 88 characters)
./tests/test_regex_identifier.py:601:89: E501 line too long (372 > 88 characters)
./tests/test_regex_identifier.py:610:89: E501 line too long (1694 > 88 characters)
./tests/test_regex_identifier.py:619:89: E501 line too long (1770 > 88 characters)
./tests/test_regex_identifier.py:628:89: E501 line too long (470 > 88 characters)
./tests/test_regex_identifier.py:637:89: E501 line too long (194 > 88 characters)
./tests/test_regex_identifier.py:646:89: E501 line too long (114 > 88 characters)
./tests/test_regex_identifier.py:700:89: E501 line too long (135 > 88 characters)
./tests/test_regex_identifier.py:771:89: E501 line too long (125 > 88 characters)
./tests/test_regex_identifier.py:780:89: E501 line too long (90 > 88 characters)
./tests/test_regex_identifier.py:793:89: E501 line too long (751 > 88 characters)
./tests/test_regex_identifier.py:802:89: E501 line too long (865 > 88 characters)
./tests/test_regex_identifier.py:879:89: E501 line too long (134 > 88 characters)
./tests/test_regex_identifier.py:893:89: E501 line too long (94 > 88 characters)
./tests/test_regex_identifier.py:932:89: E501 line too long (186 > 88 characters)
./tests/test_regex_identifier.py:1021:89: E501 line too long (92 > 88 characters)
./tests/test_regex_identifier.py:1030:89: E501 line too long (124 > 88 characters)
./tests/test_click.py:365:89: E501 line too long (169 > 88 characters)
./pywhat/printer.py:20:89: E501 line too long (139 > 88 characters)
./pywhat/printer.py:21:89: E501 line too long (106 > 88 characters)
./pywhat/printer.py:126:89: E501 line too long (143 > 88 characters)
./pywhat/printer.py:127:89: E501 line too long (109 > 88 characters)
./pywhat/what.py:81:89: E501 line too long (241 > 88 characters)
./pywhat/what.py:92:89: E501 line too long (103 > 88 characters)
./pywhat/what.py:135:89: E501 line too long (113 > 88 characters)
./pywhat/what.py:137:89: E501 line too long (90 > 88 characters)
./pywhat/what.py:139:89: E501 line too long (122 > 88 characters)
./pywhat/what.py:143:89: E501 line too long (103 > 88 characters)
./pywhat/what.py:177:89: E501 line too long (155 > 88 characters)
./pywhat/what.py:179:89: E501 line too long (133 > 88 characters)
./pywhat/what.py:183:89: E501 line too long (119 > 88 characters)
./pywhat/what.py:198:89: E501 line too long (122 > 88 characters)
./pywhat/what.py:202:89: E501 line too long (128 > 88 characters)
./pywhat/filter.py:100:9: E722 do not use bare 'except'
./pywhat/__init__.py:1:1: F401 'pywhat.filter.Distribution' imported but unused
./pywhat/__init__.py:1:1: F401 'pywhat.filter.Filter' imported but unused
./pywhat/__init__.py:2:1: F401 'pywhat.helper.Keys' imported but unused
./pywhat/__init__.py:3:1: F401 'pywhat.identifier.Identifier' imported but unused
./pywhat/helper.py:89:5: E731 do not assign a lambda expression, use a def
./pywhat/helper.py:90:5: E731 do not assign a lambda expression, use a def
./pywhat/helper.py:91:5: E731 do not assign a lambda expression, use a def
./pywhat/__main__.py:13:89: E501 line too long (124 > 88 characters)
./scripts/get_file_sigs.py:94:89: E501 line too long (96 > 88 characters)
./scripts/get_file_sigs.py:101:89: E501 line too long (175 > 88 characters)

tests/test_identifier.py Outdated Show resolved Hide resolved
Co-authored-by: piatrashkakanstantinass <[email protected]>
@jyooru
Copy link
Contributor Author

jyooru commented Oct 16, 2021

One last error left:

./pywhat/filter.py:100:9: E722 do not use bare 'except'

@piatrashkakanstantinass you added this code, do you know what exception is being excepted? I'm pretty sure it's IndexError, but I thought I would check with you.

    def __contains__(self, item):
        try:
            return (
                self["MinRarity"] <= item["Rarity"] <= self["MaxRarity"]
                and set(item["Tags"]) & self["Tags"]
                and not set(item["Tags"]) & self["ExcludeTags"]
            )
        except:
            return False

@jyooru jyooru marked this pull request as ready for review October 16, 2021 13:41
@ghost
Copy link

ghost commented Oct 16, 2021

One last error left:


./pywhat/filter.py:100:9: E722 do not use bare 'except'

@piatrashkakanstantinass you added this code, do you know what exception is being excepted? I'm pretty sure it's IndexError, but I thought I would check with you.

    def __contains__(self, item):

        try:

            return (

                self["MinRarity"] <= item["Rarity"] <= self["MaxRarity"]

                and set(item["Tags"]) & self["Tags"]

                and not set(item["Tags"]) & self["ExcludeTags"]

            )

        except:

            return False

I do not know😅. I checked it now and did not find any place for exceptions.

@jyooru jyooru requested a review from a user October 18, 2021 07:33
@codecov-commenter
Copy link

codecov-commenter commented Oct 18, 2021

Codecov Report

Merging #195 (4342bdc) into main (d6c6c00) will increase coverage by 0.14%.
The diff coverage is 91.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #195      +/-   ##
==========================================
+ Coverage   92.37%   92.52%   +0.14%     
==========================================
  Files          14       14              
  Lines        1207     1204       -3     
==========================================
- Hits         1115     1114       -1     
+ Misses         92       90       -2     
Impacted Files Coverage Δ
pywhat/what.py 81.72% <ø> (ø)
tests/test_regex_identifier.py 96.55% <ø> (-0.23%) ⬇️
pywhat/__init__.py 90.00% <50.00%> (-0.91%) ⬇️
pywhat/filter.py 87.30% <100.00%> (+2.45%) ⬆️
pywhat/helper.py 90.00% <100.00%> (+0.44%) ⬆️
tests/test_filtration.py 95.29% <100.00%> (ø)
tests/test_identifier.py 100.00% <100.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 d6c6c00...4342bdc. Read the comment docs.

@@ -222,7 +222,7 @@ def main(**kwargs):

%t - tags (in 'tag1, tag2 ...' format)

If you want to print '%' or '\' character - escape it: '\%', '\\'.
If you want to print '%' or '\\' character - escape it: '\\%', '\\\\'.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now shown correctly when printed.

Before:

If you want to print '%' or '' character - escape it: '\%', '\'.

After:

If you want to print '%' or '\' character - escape it: '\%', '\\'.

pywhat/filter.py Outdated Show resolved Hide resolved
@bee-san bee-san merged commit 75e38c6 into bee-san:main Oct 19, 2021
@jyooru jyooru deleted the flake8 branch October 19, 2021 10:13
@jyooru jyooru restored the flake8 branch October 21, 2021 12:12
@jyooru jyooru deleted the flake8 branch October 21, 2021 12:12
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.

None yet

3 participants