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

Improve String Handling #1132

Merged
merged 381 commits into from May 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
381 commits
Select commit Hold shift + click to select a range
f4455e6
[feat] Improve regex for matching strings
bbugyi200 Jan 20, 2020
0050244
[ref] Better name for regex group
bbugyi200 Jan 20, 2020
585301f
[ref] Move long_tuple under "Regression Tests" section
bbugyi200 Jan 20, 2020
324375b
[ref] Use "RE" prefix for regular expressions instead of "STRING"
bbugyi200 Jan 20, 2020
188b212
[ref] Clean up variable names
bbugyi200 Jan 20, 2020
dcf6362
[fix] Handle backslashes better
bbugyi200 Jan 20, 2020
200f422
[ref] Cleanup code for finding an even number of backslashes
bbugyi200 Jan 20, 2020
ec5ab65
[ref] Change variable name to RE_NOT_QUOTE_FMT
bbugyi200 Jan 20, 2020
bcd8124
[ref] Make RE_NOT_QUOTE a format function
bbugyi200 Jan 20, 2020
eee4150
[ref] Remove unnecessary '.replace(...)' call
bbugyi200 Jan 20, 2020
ebba5ee
[ref] Remove '_REGEXP' suffix from variable names
bbugyi200 Jan 20, 2020
d63c20e
Merge remote-tracking branch 'upstream/master' into 182-wrap-long-str…
bbugyi200 Jan 20, 2020
e8c7d1b
[sty] Blacken test_black.py
bbugyi200 Jan 20, 2020
d2fbc02
[meta-fix] Remove 'NamedTuple' import
bbugyi200 Jan 20, 2020
280bf9f
[ref] Rename variable to 'RE_EOL'
bbugyi200 Jan 20, 2020
377c306
[test] Add tests for paren stripper with old-style formatting
bbugyi200 Jan 20, 2020
78a2391
[fix] Bug with old-style formatting strippers
bbugyi200 Jan 20, 2020
9e6bd22
[ref] Factor 'get_first_unmatched_rpar_idx(...)' out of StringStrippers
bbugyi200 Jan 20, 2020
c320f2d
[fix] Fix bug with merging strings that contain backslashed quotes
bbugyi200 Jan 20, 2020
12e05fc
[fix] Don't match internal strings when stripping parens
bbugyi200 Jan 20, 2020
f9ab316
[fix] Break index must be > 1
bbugyi200 Jan 20, 2020
d0befe2
[fix] + operator was being stripped from string expressions sometimes
bbugyi200 Jan 20, 2020
2a5b19c
[fix] Don't try to merge strings in comments
bbugyi200 Jan 20, 2020
403ad14
[fix] string_idx can be set wrong if other strings on same line are d…
bbugyi200 Jan 20, 2020
9417f71
[fix] ParenStripper matches wrong string_idx
bbugyi200 Jan 20, 2020
20291c0
[fix] Comments not being counted as apart of length of string line
bbugyi200 Jan 20, 2020
096ff00
[fix] Fix test_remove_parens
bbugyi200 Jan 20, 2020
6e85d44
[fix] Fix test_comments7
bbugyi200 Jan 20, 2020
d312d40
[fix] Substring length issues
bbugyi200 Jan 21, 2020
f943d97
[ref] Remove pointless check
bbugyi200 Feb 1, 2020
6c4a335
[fix] Do not set offset==3 by default
bbugyi200 Feb 1, 2020
8a30ee8
[fix] Fix format method was being placed inconsistently
bbugyi200 Feb 1, 2020
4055e28
[fix] Fix RE_DOT_OR_PERC so it finds attributes / methods which are n…
bbugyi200 Feb 1, 2020
024b25e
[ref] Rename 'RE_BALANCED_PARENS' to 're_balanced_parens'
bbugyi200 Feb 1, 2020
0ded68d
[ref] Rename 'RE_NOT_QUOTE' to 're_not_quote'
bbugyi200 Feb 1, 2020
3fab039
[ref] Remove STMatchResult inplace of STResult[str]
bbugyi200 Feb 1, 2020
1f87d49
[ref] Rename 'MIN_WORD_SIZE' variable
bbugyi200 Feb 1, 2020
478b5eb
[ref] Move get_first_unmatched_rpar_idx(...) into StringStripperMixin…
bbugyi200 Feb 1, 2020
7f8363c
[ref] Rename 'CUSTOM_SPLITS' to 'CUSTOM_SPLIT_MAP'
bbugyi200 Feb 1, 2020
06d4941
[ref] Use helper function 'nc_group(...)' for creating non-capturing …
bbugyi200 Feb 1, 2020
a35ee85
[ref] Clean up regexp constants using non_cap_group(...)
bbugyi200 Feb 1, 2020
544a9e9
[ref] Clean up regexp constants using comments and helper functions
bbugyi200 Feb 1, 2020
a0d67b6
[ref] Added 're_' prefix to regexp helper functions
bbugyi200 Feb 1, 2020
b2deb13
[ref] Remove '?' from end of RE_DOT_OR_PERC
bbugyi200 Feb 1, 2020
6be1566
[ref] Use re_named_group(...) for RE_DOT_OR_PERC
bbugyi200 Feb 1, 2020
bf8ac0a
[ref] Clean up RE_DOT_OR_PERC
bbugyi200 Feb 1, 2020
dd96b09
[ref] Rename 're_noncap_group' to 're_group'
bbugyi200 Feb 1, 2020
f7da536
[ref] Clean up RE_BALANCED_QUOTES
bbugyi200 Feb 1, 2020
345f3e0
[ref] Clean up RE_EOL
bbugyi200 Feb 1, 2020
6cdaa75
[ref] Migrate StringExprSplitter._do_splitter_match(...) to use RE only
bbugyi200 Feb 1, 2020
5e886b2
[ref] Removed some dead code
bbugyi200 Feb 1, 2020
15ebfdc
[feat] Merge even strings that are below line_length
bbugyi200 Feb 2, 2020
c543e0e
[doc] Add docstrings to classes, helper functions, and public methods.
bbugyi200 Feb 2, 2020
e9f5cc2
[doc] Remove the 'Requirements' section from StringExprSplitterMixin'…
bbugyi200 Feb 2, 2020
0e13277
[doc] Add comment for 'annassign' bugfix
bbugyi200 Feb 2, 2020
fc6daa3
[ref] Add '?' to the end of RE_DOT_OR_PERC
bbugyi200 Feb 2, 2020
47baff0
[ref] Rename 'RE_DOT_OR_PERC' to 'RE_STRING_TRAILER'
bbugyi200 Feb 2, 2020
5f0c49b
[ref] Disambiguate StringExprSplitter.do_match(...) with regard to tr…
bbugyi200 Feb 2, 2020
79869b4
[ref] Use re.VERBOSE flag
bbugyi200 Feb 2, 2020
20f2698
[ref] Switch all REs to use re.VERBOSE styling
bbugyi200 Feb 3, 2020
e005612
[doc] Update requirements for StringArithExprSplitter
bbugyi200 Feb 3, 2020
401a791
[doc] Fix 'Requirements' section of StringArithExprSplitter
bbugyi200 Feb 3, 2020
c4be537
[fix] Fix drop_pointless_f_prefix initialization
bbugyi200 Feb 3, 2020
f4f6efd
[fix] Attempt to fix pipeline failure by making CUSTOM_SPLIT_MAP more…
bbugyi200 Feb 3, 2020
9aa0da5
[ref] Use conveniance variable (LL = line.leaves)
bbugyi200 Feb 3, 2020
a03652f
[doc] Cleanup StringTermSplitter docstring
bbugyi200 Feb 3, 2020
2dcd29a
[ref] Redefine 'STMatchResult' convieniance type
bbugyi200 Feb 8, 2020
b114c3e
[ref] Define RE_ODD_BACKSLASHES in terms of RE_EVEN_BACKSLASHES
bbugyi200 Feb 8, 2020
0a42126
[fix] Fix bug in StringMerger by changing the way string_idx is calcu…
bbugyi200 Feb 8, 2020
037f4c1
[ref] Add assertion statements for get_string_prefix(...) pre-conditions
bbugyi200 Feb 8, 2020
cd668e5
[doc] Improve some docstrings
bbugyi200 Feb 8, 2020
2425dce
[ref] Improve implementation of Result return type
bbugyi200 Feb 8, 2020
191984b
[ref] Change type of STMatchResult to STResult[Tuple[str, Optional[in…
bbugyi200 Feb 8, 2020
031cd8d
[doc] Fix return types in StringTransformerMixin method docstrings
bbugyi200 Feb 8, 2020
e85931f
[ref] Add 'LL' alias for 'line.leaves' to more methods
bbugyi200 Feb 8, 2020
37cb1f2
[doc] Change STError docstring
bbugyi200 Feb 8, 2020
179bde3
[doc] Change ValueError message that's returned from _get_string_idx(…
bbugyi200 Feb 8, 2020
4d2a727
[doc] Move STMatchResult inline comment that describes its use
bbugyi200 Feb 8, 2020
e19445f
[doc] Add 'StringIndex' type
bbugyi200 Feb 8, 2020
1a79ccb
[misc] Add debugging messages using 'split_records' to debug pipeline…
bbugyi200 Feb 8, 2020
b66cef3
[misc] Add DEBUG_SPLIT_LINE bool variable
bbugyi200 Feb 8, 2020
bc13645
[misc] Remove DEBUG_SPLIT_LINE variable
bbugyi200 Feb 8, 2020
1e3cd5a
[misc] Remove 'split_records' debugging code
bbugyi200 Feb 8, 2020
5214566
[ref] Add assert statement to check pre-conditions of 'append_leaves(…
bbugyi200 Feb 8, 2020
45958e5
[misc] Add 'err(...)' debug message when split functions fail
bbugyi200 Feb 8, 2020
f4430c9
[misc] Add debugging message inside Line.append(...)
bbugyi200 Feb 8, 2020
e3e5871
[fix] Debugging message referenced undefined variable name 'line'
bbugyi200 Feb 8, 2020
e36cda4
[fix] Don't include bracket_tracket when cloning Line
bbugyi200 Feb 8, 2020
d76912e
[misc] Removed debugging code for troubleshooting pipeline bug
bbugyi200 Feb 9, 2020
6acc677
[fix] Fix bug with comments
bbugyi200 Feb 9, 2020
1074ebc
[meta-fix] Blacken black.py
bbugyi200 Feb 9, 2020
faa74e4
[misc] Remove _regex_match(...) debugging convenience code
bbugyi200 Feb 9, 2020
150fa9a
[ref] Remove some dead code
bbugyi200 Feb 9, 2020
58bb151
[test] Add test that raw strings only get merged when all substrings …
bbugyi200 Feb 9, 2020
9ba51b1
[feat] Optimize StringTransformer matching process
bbugyi200 Feb 9, 2020
fce5b64
[ref] Remove unused argument from _regex_match(...)
bbugyi200 Feb 9, 2020
538e983
[ref] Light refactoring
bbugyi200 Feb 9, 2020
2efd79e
[doc] Clean up some docstrings
bbugyi200 Feb 9, 2020
391c832
[ref] Another light cleanup
bbugyi200 Feb 9, 2020
9aa0374
[meta] Style black.py strings using split strings format introduced i…
bbugyi200 Feb 9, 2020
7a2b9da
[ref] Check for multi-line strings in RE_STRING
bbugyi200 Feb 9, 2020
572a55b
[feat] Remove check for comments on both LPAR and RPAR
bbugyi200 Feb 9, 2020
2f1ee5f
[ref] Cleanup dead code
bbugyi200 Feb 9, 2020
bea9f8a
[meta] Blacken black.py
bbugyi200 Feb 9, 2020
dd91d2d
[ref] Refactored __merge_string_group(...)
bbugyi200 Feb 9, 2020
802f52c
[doc] Add docstring to __validate_msg(...)
bbugyi200 Feb 9, 2020
3d3cca9
[fix] StringArgCommaStripper causing comments to disappear
bbugyi200 Feb 9, 2020
f5716e4
[ref] Refactor StringArgCommaStripper comment saving process
bbugyi200 Feb 9, 2020
1558189
[feat] Don't wrap long string function args in parens anymore
bbugyi200 Feb 10, 2020
9d20583
[fix] Bug where stripping f-string 'f' char breaks custom split
bbugyi200 Feb 10, 2020
8d201ae
[fix] f-strings should not be broken in the middle of an f-expression
bbugyi200 Feb 10, 2020
9b3a91d
[fix] {{ and }} were not being replaced with { and } when dropping th…
bbugyi200 Feb 10, 2020
ca59b4c
[fix] When merging a fstring with a non-fstring, braces need to be es…
bbugyi200 Feb 10, 2020
2433537
[fix] Prefix is included in rest_line so shouldn't be in max_rest_lin…
bbugyi200 Feb 10, 2020
2122e2d
[meta] Blacken black.py
bbugyi200 Feb 10, 2020
1ac36ba
[doc] Add inline comments to __merge_string_group(...)
bbugyi200 Feb 10, 2020
8a1fd23
[doc] Add docstring to __validate(...)
bbugyi200 Feb 10, 2020
576d393
[doc] Add 'Requirements' section to StringSplitterMixin's docstring
bbugyi200 Feb 10, 2020
8f850c6
[ref] Cleanup _insert_str_child_factory(...) implementation a bit
bbugyi200 Feb 10, 2020
30c94bf
[doc] Cleanup StringMerger comments and docstring further
bbugyi200 Feb 10, 2020
bc27c55
[doc] Add 'Returns' sections to private StringMerger methods
bbugyi200 Feb 10, 2020
9241221
[ref] Use CustomSplitMixin instead of global CUSTOM_SPLIT_MAP
bbugyi200 Feb 10, 2020
c43a0eb
[doc] Add docstrings to CustomSplitMixin's methods
bbugyi200 Feb 10, 2020
fdf1980
[ref] Make CustomSplitMixin's methods static
bbugyi200 Feb 10, 2020
1044a0c
[ref] Remove STRING_CHILD_IDX_MAP
bbugyi200 Feb 10, 2020
ccd1689
[doc] Add docstring for _insert_str_child_factory(...)
bbugyi200 Feb 10, 2020
71fb99a
[doc] Add 'Examples' section to _insert_str_child_factory(...) docstring
bbugyi200 Feb 11, 2020
75734f7
[ref] Refactored the fexpr_slices(...) function
bbugyi200 Feb 11, 2020
8ab444f
[ref] Factor out __get_max_string_length_offset(...) method
bbugyi200 Feb 11, 2020
fb581de
[doc] Add docstring and inline comments to __get_max_string_length_of…
bbugyi200 Feb 11, 2020
1ac3a9e
[ref] Rename 'CustomSplitMixin' to 'CustomSplitMapMixin'
bbugyi200 Feb 11, 2020
468d18b
[doc] Cleanup a few docstrings
bbugyi200 Feb 11, 2020
3167a7a
[doc] Remove stale comment about 'PP' variable
bbugyi200 Feb 11, 2020
16ec9e1
[ref] Make fexpr_slices(...) a generator
bbugyi200 Feb 17, 2020
3c46389
[ref] Remove abstractmethod 'do_transform(...)' from StringSplitterMixin
bbugyi200 Feb 17, 2020
02364fe
[doc] Add Collaborations sections to StringParensStripper and StringE…
bbugyi200 Feb 17, 2020
1f77e2d
[doc] Fix inline comment
bbugyi200 Feb 17, 2020
f3f75ed
[ref] Rename StringTermSplitter and StringExprSplitter
bbugyi200 Feb 17, 2020
d9d76f6
[ref] Refactor and add inline comments to StringAtomicSplitter.do_tra…
bbugyi200 Feb 17, 2020
1184da6
[ref] Add __maybe_normalize_string_quotes(...)
bbugyi200 Feb 17, 2020
7642251
[ref] Cleanup __get_break_idx(...)
bbugyi200 Feb 17, 2020
3a60b69
[doc] Light docstring cleanups
bbugyi200 Feb 17, 2020
aa24bbf
[doc] Finish documenting __get_break_idx(...) and __normalize_f_strin…
bbugyi200 Feb 17, 2020
8c3665f
[ref] Rename 'conditions_are_bad' to 'fails_check'
bbugyi200 Feb 17, 2020
1b3171e
[ref] Several small improvements
bbugyi200 Feb 17, 2020
55c24b0
[ref] Refactor 'passes_all_checks(...)'
bbugyi200 Feb 17, 2020
860ac54
[ref] Rename 'split_line' to 'transform_line'
bbugyi200 Feb 17, 2020
2e65511
[fix] StringNonAtomicSplitter should handle 'yield' statements
bbugyi200 Feb 17, 2020
47c478a
[ref] Rename StringSplitterMixin to StringSplitter
bbugyi200 Feb 17, 2020
64a3bf0
[doc] Add docstrings to StringNonAtomicSplitter.do_transform(...)
bbugyi200 Feb 17, 2020
4b03e9c
[feat] Add LineTransformerError custom exception
bbugyi200 Feb 17, 2020
7592267
[ref] Rename 'split_funcs' to 'transformers'
bbugyi200 Feb 17, 2020
bb1871b
[ref] Light refactoring of CustomSplitMapMixin
bbugyi200 Feb 17, 2020
7efe5ce
[fix] Raw-string and disappearing inline comments bugs
bbugyi200 Feb 17, 2020
f50d5a3
[fix] Fallback to custom_splits if algorithmic split fails
bbugyi200 Feb 17, 2020
9694c0d
[fix] We should not give up on good splits just because the last one …
bbugyi200 Feb 17, 2020
df1de5a
[ref] Rename 'transform_line' to 'fix_line'
bbugyi200 Feb 17, 2020
e5f3721
[ref] Change '__get_max_string_length_offset' to '__get_max_string_le…
bbugyi200 Feb 17, 2020
b8b89d0
[ref] Change return type of do_match(...) to just the string index
bbugyi200 Feb 17, 2020
f4b4b04
[opt] Remove regex from StringMerger.do_match(...)
bbugyi200 Feb 17, 2020
1bd7f7c
[ref] Rename 'transformers' to 'fixers'
bbugyi200 Feb 17, 2020
1ddd666
[ref] Light refactoring
bbugyi200 Feb 17, 2020
bbc5a20
[meta] Add 'Final' type description to a few RE constants I forgot about
bbugyi200 Feb 22, 2020
783a9c6
[doc] Replace 'transform' with 'fix' everywhere found in docstrings a…
bbugyi200 Feb 22, 2020
865d2f8
[mod] Add check to assert_is_leaf_string(...) for ending quote char
bbugyi200 Feb 22, 2020
dbc00c4
[mod] Make sure in assert_is_leaf_string(...) that starting quote is …
bbugyi200 Feb 22, 2020
5c13c3f
[doc] Fix assertion error message in assert_is_leaf_string(...)
bbugyi200 Feb 22, 2020
05af4fa
[doc] Improve docstring of assert_is_leaf_string(...)
bbugyi200 Feb 22, 2020
0f242db
[mod] Made assertion in assert_is_leaf_string(...) clearer
bbugyi200 Feb 22, 2020
4b62987
[doc] Make ending quote assertion error consistent in assert_is_leaf_…
bbugyi200 Feb 22, 2020
1f4395f
[ref] Made methods of CustomSplitMapMixin non-static
bbugyi200 Feb 22, 2020
9796abb
[doc] Make 'Pre-Conditions' section of assert_is_leaf_string(...) doc…
bbugyi200 Feb 22, 2020
459eb35
[add] StringTrailerParser class and convert StringParensStripper.do_m…
bbugyi200 Feb 22, 2020
66ff18b
[mod] Migrate StringAtomicSplitter.do_match(...) over to using String…
bbugyi200 Feb 22, 2020
383cbda
[mod] Migrate StringNonAtomicSplitter.do_match(...) over to parsing i…
bbugyi200 Feb 22, 2020
99cfe0f
[add] Temporary(?) DEBUG variable
bbugyi200 Feb 22, 2020
a07fee3
[rem] Remove dead code (mostly regex related stuff)
bbugyi200 Feb 22, 2020
d35f7a7
[rem] Remove STP_State class
bbugyi200 Feb 22, 2020
535457b
[ref] Factor out _*_match(...) methods from StringNonAtomicSplitter.d…
bbugyi200 Feb 22, 2020
15597c5
[rem] `line_str` param from StringFixer dataclass
bbugyi200 Feb 22, 2020
c3b2444
[ref] Remove `__PATTERN_CACHE`
bbugyi200 Feb 22, 2020
8b4a787
[ref] Reduce cyclomatic complexity of StringAtomicSplitter.do_match(...)
bbugyi200 Feb 23, 2020
3965b87
[fix] StringMerger should not merge multiline strings
bbugyi200 Feb 23, 2020
cd46e2a
[fix] Removed bad assertion
bbugyi200 Feb 23, 2020
8b812fb
[fix] Better fix for merging of triple-quoted strings
bbugyi200 Feb 23, 2020
a2aa50e
[fix] ParenStripper shouldn't be stripping function call parens
bbugyi200 Feb 23, 2020
9deb2ac
[ref] Move regular expression definitions to before first use
bbugyi200 Feb 23, 2020
5508aa0
[ref] General cleanup and better use of utility functions
bbugyi200 Feb 23, 2020
b77bb70
[meta] Fix type of is_valid_index_factory(...) paramater
bbugyi200 Feb 23, 2020
efbb4a4
[ref] Use is_valid_index(...) in StringParensStripper.do_match(...)
bbugyi200 Feb 23, 2020
e61a4a9
[ref] General Cleanup
bbugyi200 Feb 23, 2020
d8ce3c9
[doc] Add docstrings to helper functions
bbugyi200 Feb 23, 2020
43abdff
[ref] Rename Fixer back to Transformer
bbugyi200 Feb 23, 2020
98a8980
[meta] Blacken black.py
bbugyi200 Feb 23, 2020
7c10af0
[ref] Rename 'cant_fix' to 'cant_trans'
bbugyi200 Feb 23, 2020
623e1d5
[meta] Remove unused imports
bbugyi200 Feb 29, 2020
d9ea0e8
[ref] Rename 'parser' to 'string_parser'
bbugyi200 Feb 29, 2020
c483068
[doc] Fix Examples section of docstring
bbugyi200 Feb 29, 2020
e17ab14
[doc] Add inline comments describing StringParser state map
bbugyi200 Feb 29, 2020
c5463a9
[ref] Move conditional logic from do_match(...) to _*_match(...) methods
bbugyi200 Feb 29, 2020
3577e67
[doc] Add example to StringParser docstring
bbugyi200 Feb 29, 2020
dd5f5d0
[ref] Make StringParser instance attributes "protected"
bbugyi200 Feb 29, 2020
d02f0e2
[doc] Add docstrings to _*_match(...) methods
bbugyi200 Feb 29, 2020
8014070
[ref] Make _insert_str_child_factory a stand-alone function
bbugyi200 Feb 29, 2020
3152efd
[doc] Fix docstring of transform_line(...)
bbugyi200 Feb 29, 2020
72d5a6c
[ref] Add TErr(...) convenience function
bbugyi200 Feb 29, 2020
70bc9e1
[ref] Cleanup StringParser implementation
bbugyi200 Feb 29, 2020
9c24fbc
[rem] Remove DEBUG variable
bbugyi200 Feb 29, 2020
b6fad8a
[ref] Cleanup StringParensStripper.do_match(...)
bbugyi200 Feb 29, 2020
7028820
[doc] Add inline comments to StringAtomicSplitter.do_splitter_match(...)
bbugyi200 Feb 29, 2020
ddc8cb6
[doc] Add inline comments to annotate StringParser's usage
bbugyi200 Feb 29, 2020
0ad3dbf
[doc] Fix inline comment
bbugyi200 Feb 29, 2020
20bd607
[doc] Move description of RE_FEXPR to inline comment above definition
bbugyi200 Feb 29, 2020
5c9b14c
[ref] Rename 'cant_trans' to 'cant_transform'
bbugyi200 Feb 29, 2020
b2b973d
[ref] Cleanup StringNonAtomicSplitter._return_match(...)
bbugyi200 Feb 29, 2020
4c0ce31
[doc] Add inline comments to StringNonAtomicSplitter._else_match(...)
bbugyi200 Feb 29, 2020
c911fa3
[test] Add good test for long f-strings
bbugyi200 Feb 29, 2020
d585f73
[doc] Add inline comments to the rest of the StringNonAtomicSplitter.…
bbugyi200 Feb 29, 2020
91f145c
[ref] Rename concrete StringTransformers
bbugyi200 Feb 29, 2020
0b912b8
[doc] Cleanup docs
bbugyi200 Feb 29, 2020
08d3994
[doc] Clean up documentation
bbugyi200 Mar 7, 2020
fc8be81
[mod] Make pragma regex more restrictive (no caps)
bbugyi200 Mar 7, 2020
5a1fbec
[ref] Rename CantSplit back to CannotSplit
bbugyi200 Mar 7, 2020
624e14b
[test] Fix the test strings which had a space at the end of the line
bbugyi200 Mar 8, 2020
fcb324a
[fix] Do NOT merge strings which end in common comment pragmas
bbugyi200 Mar 8, 2020
00f1058
[doc] Add docstring to contains_pragma_comment(...)
bbugyi200 Mar 8, 2020
523e4fe
[ref] Rename 'msg' to 'err_msg'
bbugyi200 Mar 14, 2020
8d5a0a3
[test] Fix string in tests/data/composition.py to place whitespace at…
bbugyi200 Mar 14, 2020
118dd35
[rem] Remove history.txt file (committed by mistake)
bbugyi200 Mar 14, 2020
127f70d
[ref] Factor out CustomSplitMapMixin._get_key(...) method
bbugyi200 Mar 14, 2020
fa83c8c
[doc] Add docstring to CustomSplitMapMixin._get_key(...)
bbugyi200 Mar 14, 2020
8401ebb
[ref] CustomSplitMapMixin should be first in MRO
bbugyi200 Mar 14, 2020
1cf0164
[test] Split long_strings.py data file into 3 files
bbugyi200 Mar 14, 2020
ad48554
[fix] Fix "undefined name '_Key'" flake8 error
bbugyi200 Mar 14, 2020
1e37234
[ref] Cleanup StringMerger.__validate_msg(...)
bbugyi200 Mar 14, 2020
e6e6503
[ref] Simplify StringParenStripper by using StringParser()
bbugyi200 Mar 14, 2020
8c36312
[ref] Rename 'target_idx' to 'ideal_idx'
bbugyi200 Mar 14, 2020
8579c5b
[ref] Move 'ends_with_comma' outside of 'max_last_string(...)'
bbugyi200 Mar 14, 2020
e8120a0
Merge remote-tracking branch 'upstream/master' into 182-wrap-long-str…
bbugyi200 Mar 14, 2020
8d86723
[meta] Blacken gallary/gallary.py
bbugyi200 Mar 14, 2020
3aeb407
[fix] Fix bug revealed by #1243
bbugyi200 Mar 15, 2020
6c1f2c4
[fix] We should not wrap long strings in parens when they will still …
bbugyi200 Mar 15, 2020
8aeb6f4
[test] Fix test_remove_parens
bbugyi200 Mar 15, 2020
4424dd1
[ref] Inherit from CustomSplitMapMixin before BaseStringSplitter
bbugyi200 Mar 15, 2020
a650d75
[test] Correct test data strings so they make sense
bbugyi200 Mar 15, 2020
eb77cb2
[ref] Rename 'ideal_idx' to 'max_break_idx'
bbugyi200 Mar 16, 2020
d33621d
[ref] Make MIN_SUBSTR_SIZE a class variable
bbugyi200 Mar 16, 2020
71f8816
[doc] Add inline comments to StringParenWrapper.do_splitter_match(...)
bbugyi200 Mar 16, 2020
6ce679f
[ref] Add CustomSplitMapMixin.has_custom_splits(...) helper method
bbugyi200 Mar 16, 2020
d576686
[doc] Remove surrounding parens from inline comment
bbugyi200 Apr 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2,164 changes: 2,083 additions & 81 deletions black.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions blib2to3/pgen2/pgen.py
Expand Up @@ -167,8 +167,8 @@ def calcfirst(self, name: Text) -> None:
for symbol in itsfirst:
if symbol in inverse:
raise ValueError(
"rule %s is ambiguous; %s is in the"
" first sets of %s as well as %s"
"rule %s is ambiguous; %s is in the first sets of %s as well"
" as %s"
% (name, symbol, label, inverse[symbol])
)
inverse[symbol] = label
Expand Down
4 changes: 3 additions & 1 deletion blib2to3/pgen2/tokenize.py
Expand Up @@ -78,7 +78,9 @@ def _combinations(*l):
Whitespace = r"[ \f\t]*"
Comment = r"#[^\r\n]*"
Ignore = Whitespace + any(r"\\\r?\n" + Whitespace) + maybe(Comment)
Name = r"\w+" # this is invalid but it's fine because Name comes after Number in all groups
Name = ( # this is invalid but it's fine because Name comes after Number in all groups
r"\w+"
)

Binnumber = r"0[bB]_?[01]+(?:_[01]+)*"
Hexnumber = r"0[xX]_?[\da-fA-F]+(?:_[\da-fA-F]+)*[lL]?"
Expand Down
3 changes: 1 addition & 2 deletions gallery/gallery.py
Expand Up @@ -268,8 +268,7 @@ def main() -> None:
"-v",
"--version",
help=(
"Version for given PyPI package. "
"Will be discarded if used with -t option."
"Version for given PyPI package. Will be discarded if used with -t option."
),
)
parser.add_argument(
Expand Down
12 changes: 7 additions & 5 deletions tests/data/cantfit.py
Expand Up @@ -35,7 +35,7 @@
""".split():
if key in self.connect_kwargs:
raise ValueError(err.format(key))
concatenated_strings = "some strings that are" "concatenated implicitly, so if you put them on separate" "lines it will fit"
concatenated_strings = "some strings that are " "concatenated implicitly, so if you put them on separate " "lines it will fit"
del concatenated_strings, string_variable_name, normal_function_name, normal_name, need_more_to_make_the_line_long_enough


Expand Down Expand Up @@ -75,8 +75,10 @@
)
# long arguments
normal_name = normal_function_name(
"but with super long string arguments that on their own exceed the line limit so there's no way it can ever fit",
"eggs with spam and eggs and spam with eggs with spam and eggs and spam with eggs with spam and eggs and spam with eggs",
"but with super long string arguments that on their own exceed the line limit so"
" there's no way it can ever fit",
"eggs with spam and eggs and spam with eggs with spam and eggs and spam with eggs"
" with spam and eggs and spam with eggs",
this_is_a_ridiculously_long_name_and_nobody_in_their_right_mind_would_use_one_like_it=0,
)
string_variable_name = "a string that is waaaaaaaayyyyyyyy too long, even in parens, there's nothing you can do" # noqa
Expand All @@ -88,8 +90,8 @@
if key in self.connect_kwargs:
raise ValueError(err.format(key))
concatenated_strings = (
"some strings that are"
"concatenated implicitly, so if you put them on separate"
"some strings that are "
"concatenated implicitly, so if you put them on separate "
"lines it will fit"
)
del (
Expand Down
42 changes: 16 additions & 26 deletions tests/data/comments4.py
Expand Up @@ -13,49 +13,39 @@ class C:
# metadata_version errors.
(
{},
"None is an invalid value for Metadata-Version. "
"Error: This field is required. "
"see "
"https://packaging.python.org/specifications/core-metadata",
"None is an invalid value for Metadata-Version. Error: This field is"
" required. see"
" https://packaging.python.org/specifications/core-metadata",
),
(
{"metadata_version": "-1"},
"'-1' is an invalid value for Metadata-Version. "
"Error: Unknown Metadata Version "
"see "
"https://packaging.python.org/specifications/core-metadata",
"'-1' is an invalid value for Metadata-Version. Error: Unknown Metadata"
" Version see"
" https://packaging.python.org/specifications/core-metadata",
),
# name errors.
(
{"metadata_version": "1.2"},
"'' is an invalid value for Name. "
"Error: This field is required. "
"see "
"https://packaging.python.org/specifications/core-metadata",
"'' is an invalid value for Name. Error: This field is required. see"
" https://packaging.python.org/specifications/core-metadata",
),
(
{"metadata_version": "1.2", "name": "foo-"},
"'foo-' is an invalid value for Name. "
"Error: Must start and end with a letter or numeral and "
"contain only ascii numeric and '.', '_' and '-'. "
"see "
"https://packaging.python.org/specifications/core-metadata",
"'foo-' is an invalid value for Name. Error: Must start and end with a"
" letter or numeral and contain only ascii numeric and '.', '_' and"
" '-'. see https://packaging.python.org/specifications/core-metadata",
),
# version errors.
(
{"metadata_version": "1.2", "name": "example"},
"'' is an invalid value for Version. "
"Error: This field is required. "
"see "
"https://packaging.python.org/specifications/core-metadata",
"'' is an invalid value for Version. Error: This field is required. see"
" https://packaging.python.org/specifications/core-metadata",
),
(
{"metadata_version": "1.2", "name": "example", "version": "dog"},
"'dog' is an invalid value for Version. "
"Error: Must start and end with a letter or numeral and "
"contain only ascii numeric and '.', '_' and '-'. "
"see "
"https://packaging.python.org/specifications/core-metadata",
"'dog' is an invalid value for Version. Error: Must start and end with"
" a letter or numeral and contain only ascii numeric and '.', '_' and"
" '-'. see https://packaging.python.org/specifications/core-metadata",
),
],
)
Expand Down
4 changes: 3 additions & 1 deletion tests/data/comments6.py
Expand Up @@ -104,7 +104,9 @@ def func(
)


result = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # aaa
result = ( # aaa
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)

AAAAAAAAAAAAA = [AAAAAAAAAAAAA] + SHARED_AAAAAAAAAAAAA + USER_AAAAAAAAAAAAA + AAAAAAAAAAAAA # type: ignore

Expand Down
8 changes: 6 additions & 2 deletions tests/data/comments7.py
Expand Up @@ -87,9 +87,13 @@ def func():

result = 1 # look ma, no comment migration xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

result = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # aaa
result = ( # aaa
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)

result = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" # aaa
result = ( # aaa
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)


def func():
Expand Down
15 changes: 7 additions & 8 deletions tests/data/composition.py
Expand Up @@ -10,13 +10,13 @@ def test(self) -> None:
)
self.assertEqual(
unstyle(str(report)),
"2 files reformatted, 1 file left unchanged, "
"1 file failed to reformat.",
"2 files reformatted, 1 file left unchanged, 1 file failed to"
" reformat.",
)
self.assertEqual(
unstyle(str(report)),
"2 files reformatted, 2 files left unchanged, "
"2 files failed to reformat.",
"2 files reformatted, 2 files left unchanged, 2 files failed to"
" reformat.",
)
for i in (a,):
if (
Expand All @@ -40,8 +40,7 @@ def test(self) -> None:
items=items[:num_items]
)
return (
"Utterly failed doctest test for %s\n"
' File "%s", line %s, in %s\n\n%s'
'Utterly failed doctest test for %s\n File "%s", line %s, in %s\n\n%s'
% (test.name, test.filename, lineno, lname, err)
)

Expand Down Expand Up @@ -150,8 +149,8 @@ def tricky_asserts(self) -> None:
key8: value8,
key9: value9,
}, (
"Not what we expected and the message is too long to fit "
"in one line because it's too long"
"Not what we expected and the message is too long to fit in one line"
" because it's too long"
)

dis_c_instance_method = """\
Expand Down