Skip to content

Commit

Permalink
flake8 (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaonc authored Apr 10, 2022
1 parent 203356f commit 78c31b4
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ jobs:
run: isort .
- name: black
run: black .
- name: flake8
run: flake8 .
2 changes: 1 addition & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Add `sort_dict` option (thanks @gergelyk).
* Use `pytest` instead of `nose` (thanks @pgajdos).
* Use GitHub Actions instead of Travis.
* Linting (isort, black, etc.).
* Linting: `isort`, `black`, `flake8`.
Wrapping at 100 lines from the previous 80.
* Other file and folder restructuring.

Expand Down
79 changes: 40 additions & 39 deletions pprintpp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
__all__ = ["pprint", "pformat", "isreadable", "isrecursive", "saferepr", "PrettyPrinter"]


chr_to_ascii = lambda x: ascii(x)[1:-1]
def chr_to_ascii(c):
return ascii(c)[1:-1]


def _sorted(iterable):
Expand Down Expand Up @@ -42,44 +43,44 @@ def getvalue(self):
# Source: http://www.unicode.org/reports/tr44/#GC_Values_Table
# fmt: off
unicode_printable_categories = {
"Lu": 1, # Uppercase_Letter an uppercase letter
"Ll": 1, # Lowercase_Letter a lowercase letter
"Lt": 1, # Titlecase_Letter a digraphic character, with first part uppercase
"LC": 1, # Cased_Letter Lu | Ll | Lt
"Lm": 0, # Modifier_Letter a modifier letter
"Lo": 1, # Other_Letter other letters, including syllables and ideographs
"L": 1, # Letter Lu | Ll | Lt | Lm | Lo
"Mn": 0, # Nonspacing_Mark a nonspacing combining mark (zero advance width)
"Mc": 0, # Spacing_Mark a spacing combining mark (positive advance width)
"Me": 0, # Enclosing_Mark an enclosing combining mark
"M": 1, # Mark Mn | Mc | Me
"Nd": 1, # Decimal_Number a decimal digit
"Nl": 1, # Letter_Number a letterlike numeric character
"No": 1, # Other_Number a numeric character of other type
"N": 1, # Number Nd | Nl | No
"Pc": 1, # Connector_Punctuation a connecting punctuation mark, like a tie
"Pd": 1, # Dash_Punctuation a dash or hyphen punctuation mark
"Ps": 1, # Open_Punctuation an opening punctuation mark (of a pair)
"Pe": 1, # Close_Punctuation a closing punctuation mark (of a pair)
"Pi": 1, # Initial_Punctuation an initial quotation mark
"Pf": 1, # Final_Punctuation a final quotation mark
"Po": 1, # Other_Punctuation a punctuation mark of other type
"P": 1, # Punctuation Pc | Pd | Ps | Pe | Pi | Pf | Po
"Sm": 1, # Math_Symbol a symbol of mathematical use
"Sc": 1, # Currency_Symbol a currency sign
"Sk": 1, # Modifier_Symbol a non-letterlike modifier symbol
"So": 1, # Other_Symbol a symbol of other type
"S": 1, # Symbol Sm | Sc | Sk | So
"Zs": 0, # Space_Separator a space character (of various non-zero widths)
"Zl": 0, # Line_Separator U+2028 LINE SEPARATOR only
"Zp": 0, # Paragraph_Separator U+2029 PARAGRAPH SEPARATOR only
"Z": 1, # Separator Zs | Zl | Zp
"Cc": 0, # Control a C0 or C1 control code
"Cf": 0, # Format a format control character
"Cs": 0, # Surrogate a surrogate code point
"Co": 0, # Private_Use a private-use character
"Cn": 0, # Unassigned a reserved unassigned code point or a noncharacter
"C": 0, # Other Cc | Cf | Cs | Co | Cn
"Lu": 1, # Uppercase_Letter an uppercase letter
"Ll": 1, # Lowercase_Letter a lowercase letter
"Lt": 1, # Titlecase_Letter a digraphic character, with first part uppercase
"LC": 1, # Cased_Letter Lu | Ll | Lt
"Lm": 0, # Modifier_Letter a modifier letter
"Lo": 1, # Other_Letter other letters, including syllables and ideographs
"L": 1, # Letter Lu | Ll | Lt | Lm | Lo
"Mn": 0, # Nonspacing_Mark a nonspacing combining mark (zero advance width)
"Mc": 0, # Spacing_Mark a spacing combining mark (positive advance width)
"Me": 0, # Enclosing_Mark an enclosing combining mark
"M": 1, # Mark Mn | Mc | Me
"Nd": 1, # Decimal_Number a decimal digit
"Nl": 1, # Letter_Number a letterlike numeric character
"No": 1, # Other_Number a numeric character of other type
"N": 1, # Number Nd | Nl | No
"Pc": 1, # Connector_Punctuation a connecting punctuation mark, like a tie
"Pd": 1, # Dash_Punctuation a dash or hyphen punctuation mark
"Ps": 1, # Open_Punctuation an opening punctuation mark (of a pair)
"Pe": 1, # Close_Punctuation a closing punctuation mark (of a pair)
"Pi": 1, # Initial_Punctuation an initial quotation mark
"Pf": 1, # Final_Punctuation a final quotation mark
"Po": 1, # Other_Punctuation a punctuation mark of other type
"P": 1, # Punctuation Pc | Pd | Ps | Pe | Pi | Pf | Po
"Sm": 1, # Math_Symbol a symbol of mathematical use
"Sc": 1, # Currency_Symbol a currency sign
"Sk": 1, # Modifier_Symbol a non-letterlike modifier symbol
"So": 1, # Other_Symbol a symbol of other type
"S": 1, # Symbol Sm | Sc | Sk | So
"Zs": 0, # Space_Separator a space character (of various non-zero widths)
"Zl": 0, # Line_Separator U+2028 LINE SEPARATOR only
"Zp": 0, # Paragraph_Separator U+2029 PARAGRAPH SEPARATOR only
"Z": 1, # Separator Zs | Zl | Zp
"Cc": 0, # Control a C0 or C1 control code
"Cf": 0, # Format a format control character
"Cs": 0, # Surrogate a surrogate code point
"Co": 0, # Private_Use a private-use character
"Cn": 0, # Unassigned a reserved unassigned code point or a noncharacter
"C": 0, # Other Cc | Cf | Cs | Co | Cn
}
# fmt: on

Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
black==22.3.0
flake8==4.0.1
isort==5.10.1
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[bdist_wheel]
universal = 1

[flake8]
exclude = .git,.github,.venv,__pycache__
max-line-length = 100
13 changes: 7 additions & 6 deletions tests/test_pprintpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from contextlib import redirect_stdout

import pytest
import pprintpp as p
from pprintpp import defaultdict

sys.path.append("pp/")
import pp
import pprintpp as p
from pprintpp import Counter, OrderedDict, defaultdict
import pp # noqa: E402 module level import not at top of file


def test_pp():
Expand Down Expand Up @@ -47,9 +47,10 @@ def test_module_like():

uni_safe = "\xe9 \u6f02 \u0e4f \u2661"
uni_unsafe = "\u200a \u0302 \n"
slashed = lambda s: u"'%s'" % (
s.encode("ascii", "backslashreplace").decode("ascii").replace("\n", "\\n")
)


def slashed(s):
return "'%s'" % s.encode("ascii", "backslashreplace").decode("ascii").replace("\n", "\\n")


@pytest.mark.skip('fix')
Expand Down

0 comments on commit 78c31b4

Please sign in to comment.