pyflyby 1.9.12__tar.gz → 1.9.13__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pyflyby might be problematic. Click here for more details.

Files changed (161) hide show
  1. {pyflyby-1.9.12/lib/python/pyflyby.egg-info → pyflyby-1.9.13}/PKG-INFO +1 -1
  2. {pyflyby-1.9.12/lib/python → pyflyby-1.9.13/bin}/pyflyby/_format.py +10 -6
  3. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_importstmt.py +7 -7
  4. {pyflyby-1.9.12/lib/python → pyflyby-1.9.13/bin}/pyflyby/_version.py +1 -1
  5. {pyflyby-1.9.12/bin → pyflyby-1.9.13/lib/python}/pyflyby/_format.py +10 -6
  6. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_importstmt.py +7 -7
  7. {pyflyby-1.9.12/bin → pyflyby-1.9.13/lib/python}/pyflyby/_version.py +1 -1
  8. {pyflyby-1.9.12 → pyflyby-1.9.13/lib/python/pyflyby.egg-info}/PKG-INFO +1 -1
  9. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_imports2s.py +48 -0
  10. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_importstmt.py +23 -0
  11. {pyflyby-1.9.12 → pyflyby-1.9.13}/.pyflyby +0 -0
  12. {pyflyby-1.9.12 → pyflyby-1.9.13}/LICENSE.txt +0 -0
  13. {pyflyby-1.9.12 → pyflyby-1.9.13}/MANIFEST.in +0 -0
  14. {pyflyby-1.9.12 → pyflyby-1.9.13}/README.rst +0 -0
  15. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/autoipython +0 -0
  16. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/autopython +0 -0
  17. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/collect-exports +0 -0
  18. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/collect-imports +0 -0
  19. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/create-imports +0 -0
  20. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/find-import +0 -0
  21. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/list-bad-xrefs +0 -0
  22. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/prune-broken-imports +0 -0
  23. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/py +0 -0
  24. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/__init__.py +0 -0
  25. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/__main__.py +0 -0
  26. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_autoimp.py +0 -0
  27. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_cmdline.py +0 -0
  28. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_comms.py +0 -0
  29. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_dbg.py +0 -0
  30. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_docxref.py +0 -0
  31. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_dynimp.py +0 -0
  32. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_file.py +0 -0
  33. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_flags.py +0 -0
  34. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_idents.py +0 -0
  35. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_import_sorting.py +0 -0
  36. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_importclns.py +0 -0
  37. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_importdb.py +0 -0
  38. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_imports2s.py +0 -0
  39. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_interactive.py +0 -0
  40. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_livepatch.py +0 -0
  41. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_log.py +0 -0
  42. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_modules.py +0 -0
  43. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_parse.py +0 -0
  44. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_py.py +0 -0
  45. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_saveframe.py +0 -0
  46. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_saveframe_reader.py +0 -0
  47. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/_util.py +0 -0
  48. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/autoimport.py +0 -0
  49. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby/importdb.py +0 -0
  50. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/pyflyby-diff +0 -0
  51. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/reformat-imports +0 -0
  52. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/replace-star-imports +0 -0
  53. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/saveframe +0 -0
  54. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/tidy-imports +0 -0
  55. {pyflyby-1.9.12 → pyflyby-1.9.13}/bin/transform-imports +0 -0
  56. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/LICENSE.txt +0 -0
  57. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/Makefile +0 -0
  58. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/TODO.txt +0 -0
  59. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/__init__.py +0 -0
  60. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/api.rst +0 -0
  61. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/autoimp.rst +0 -0
  62. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/cmdline.rst +0 -0
  63. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/comms.rst +0 -0
  64. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/dbg.rst +0 -0
  65. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/file.rst +0 -0
  66. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/flags.rst +0 -0
  67. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/format.rst +0 -0
  68. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/idents.rst +0 -0
  69. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/importclns.rst +0 -0
  70. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/importdb.rst +0 -0
  71. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/imports2s.rst +0 -0
  72. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/importstmt.rst +0 -0
  73. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/interactive.rst +0 -0
  74. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/livepatch.rst +0 -0
  75. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/log.rst +0 -0
  76. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/modules.rst +0 -0
  77. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/parse.rst +0 -0
  78. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/py.rst +0 -0
  79. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/api/util.rst +0 -0
  80. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/cli/autoipython.rst +0 -0
  81. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/cli/cli.rst +0 -0
  82. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/cli/collect_exports.rst +0 -0
  83. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/cli/collect_imports.rst +0 -0
  84. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/cli/find_import.rst +0 -0
  85. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/cli/prune_broken_imports.rst +0 -0
  86. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/cli/py.rst +0 -0
  87. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/cli/pyflyby_diff.rst +0 -0
  88. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/cli/reformat_imports.rst +0 -0
  89. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/cli/replace_star_imports.rst +0 -0
  90. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/cli/tidy_imports.rst +0 -0
  91. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/cli/transform_imports.rst +0 -0
  92. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/conf.py +0 -0
  93. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/index.rst +0 -0
  94. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/make.bat +0 -0
  95. {pyflyby-1.9.12 → pyflyby-1.9.13}/doc/testing.txt +0 -0
  96. {pyflyby-1.9.12 → pyflyby-1.9.13}/etc/pyflyby/canonical.py +0 -0
  97. {pyflyby-1.9.12 → pyflyby-1.9.13}/etc/pyflyby/common.py +0 -0
  98. {pyflyby-1.9.12 → pyflyby-1.9.13}/etc/pyflyby/forget.py +0 -0
  99. {pyflyby-1.9.12 → pyflyby-1.9.13}/etc/pyflyby/mandatory.py +0 -0
  100. {pyflyby-1.9.12 → pyflyby-1.9.13}/etc/pyflyby/numpy.py +0 -0
  101. {pyflyby-1.9.12 → pyflyby-1.9.13}/etc/pyflyby/std.py +0 -0
  102. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/emacs/pyflyby.el +0 -0
  103. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/__init__.py +0 -0
  104. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/__main__.py +0 -0
  105. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_autoimp.py +0 -0
  106. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_cmdline.py +0 -0
  107. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_comms.py +0 -0
  108. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_dbg.py +0 -0
  109. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_docxref.py +0 -0
  110. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_dynimp.py +0 -0
  111. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_file.py +0 -0
  112. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_flags.py +0 -0
  113. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_idents.py +0 -0
  114. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_import_sorting.py +0 -0
  115. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_importclns.py +0 -0
  116. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_importdb.py +0 -0
  117. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_imports2s.py +0 -0
  118. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_interactive.py +0 -0
  119. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_livepatch.py +0 -0
  120. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_log.py +0 -0
  121. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_modules.py +0 -0
  122. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_parse.py +0 -0
  123. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_py.py +0 -0
  124. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_saveframe.py +0 -0
  125. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_saveframe_reader.py +0 -0
  126. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/_util.py +0 -0
  127. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/autoimport.py +0 -0
  128. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby/importdb.py +0 -0
  129. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby.egg-info/SOURCES.txt +0 -0
  130. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby.egg-info/dependency_links.txt +0 -0
  131. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby.egg-info/entry_points.txt +0 -0
  132. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby.egg-info/requires.txt +0 -0
  133. {pyflyby-1.9.12 → pyflyby-1.9.13}/lib/python/pyflyby.egg-info/top_level.txt +0 -0
  134. {pyflyby-1.9.12 → pyflyby-1.9.13}/libexec/pyflyby/colordiff +0 -0
  135. {pyflyby-1.9.12 → pyflyby-1.9.13}/libexec/pyflyby/diff-colorize +0 -0
  136. {pyflyby-1.9.12 → pyflyby-1.9.13}/pyproject.toml +0 -0
  137. {pyflyby-1.9.12 → pyflyby-1.9.13}/setup.cfg +0 -0
  138. {pyflyby-1.9.12 → pyflyby-1.9.13}/setup.py +0 -0
  139. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/__init__.py +0 -0
  140. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_0testconfig.py +0 -0
  141. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_autoimp.py +0 -0
  142. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_cmdline.py +0 -0
  143. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_docxref.py +0 -0
  144. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_file.py +0 -0
  145. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_flags.py +0 -0
  146. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_format.py +0 -0
  147. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_idents.py +0 -0
  148. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_importclns.py +0 -0
  149. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_importdb.py +0 -0
  150. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_interactive.py +0 -0
  151. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_jupyterlab_pyflyby.py +0 -0
  152. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_livepatch.py +0 -0
  153. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_modules.py +0 -0
  154. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_parse.py +0 -0
  155. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_py.py +0 -0
  156. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_saveframe.py +0 -0
  157. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_saveframe_reader.py +0 -0
  158. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/test_util.py +0 -0
  159. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/tests_sorts.py +0 -0
  160. {pyflyby-1.9.12 → pyflyby-1.9.13}/tests/xrefs.py +0 -0
  161. {pyflyby-1.9.12 → pyflyby-1.9.13}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyflyby
3
- Version: 1.9.12
3
+ Version: 1.9.13
4
4
  Summary: pyflyby - Python development productivity tools, in particular automatic import management
5
5
  Home-page: https://pypi.org/project/pyflyby/
6
6
  Author: Karl Chen
@@ -6,7 +6,7 @@
6
6
 
7
7
  class FormatParams(object):
8
8
  max_line_length = None
9
- _max_line_lenght_default = 79
9
+ max_line_length_default = 79
10
10
  wrap_paren = True
11
11
  indent = 4
12
12
  hanging_indent = 'never'
@@ -128,11 +128,15 @@ def pyfill(prefix, tokens, params=FormatParams()):
128
128
  :rtype:
129
129
  ``str``
130
130
  """
131
- N = params.max_line_length or params._max_line_lenght_default
131
+ if params.max_line_length is None:
132
+ max_line_length = params.max_line_length_default
133
+ else:
134
+ max_line_length = params.max_line_length
135
+
132
136
  if params.wrap_paren:
133
137
  # Check how we will break up the tokens.
134
138
  len_full = sum(len(tok) for tok in tokens) + 2 * (len(tokens)-1)
135
- if len(prefix) + len_full <= N:
139
+ if len(prefix) + len_full <= max_line_length:
136
140
  # The entire thing fits on one line; no parens needed. We check
137
141
  # this first because breaking into lines adds paren overhead.
138
142
  #
@@ -153,7 +157,7 @@ def pyfill(prefix, tokens, params=FormatParams()):
153
157
  # longest token since even if the first token fits, we still want
154
158
  # to avoid later tokens running over N.
155
159
  maxtoklen = max(len(token) for token in tokens)
156
- hanging_indent = (len(prefix) + maxtoklen + 2 > N)
160
+ hanging_indent = (len(prefix) + maxtoklen + 2 > max_line_length)
157
161
  else:
158
162
  raise ValueError("bad params.hanging_indent=%r"
159
163
  % (params.hanging_indent,))
@@ -166,7 +170,7 @@ def pyfill(prefix, tokens, params=FormatParams()):
166
170
  # abc, defgh, ijkl,
167
171
  # mnopq, rst)
168
172
  return (prefix + "(\n"
169
- + fill(tokens, max_line_length=N,
173
+ + fill(tokens, max_line_length=max_line_length,
170
174
  prefix=(" " * params.indent), suffix=("", ")")))
171
175
  else:
172
176
  # Non-hanging-indent mode.
@@ -176,7 +180,7 @@ def pyfill(prefix, tokens, params=FormatParams()):
176
180
  # ijkl, mnopq,
177
181
  # rst)
178
182
  pprefix = prefix + "("
179
- return fill(tokens, max_line_length=N,
183
+ return fill(tokens, max_line_length=max_line_length,
180
184
  prefix=(pprefix, " " * len(pprefix)), suffix=("", ")"))
181
185
  else:
182
186
  raise NotImplementedError
@@ -512,7 +512,7 @@ class ImportStatement:
512
512
 
513
513
  return tuple(self.aliases[0][0].split('.'))
514
514
 
515
-
515
+
516
516
  def _cmp(self):
517
517
  """
518
518
  Comparison function for sorting.
@@ -587,12 +587,12 @@ class ImportStatement:
587
587
 
588
588
  black_config = read_black_config()
589
589
  mode = dict()
590
- if "line_length" in black_config:
591
- mode["line_length"] = (
592
- params.max_line_length
593
- if params.max_line_length
594
- else black_config["line_length"]
595
- )
590
+
591
+ if params.max_line_length is None:
592
+ mode["line_length"] = black_config.get("line_length", params.max_line_length_default)
593
+ else:
594
+ mode["line_length"] = params.max_line_length
595
+
596
596
  if "target_version" in black_config:
597
597
  if isinstance(black_config["target_version"], set):
598
598
  target_versions_in = black_config["target_version"]
@@ -4,4 +4,4 @@
4
4
  # http://creativecommons.org/publicdomain/zero/1.0/
5
5
 
6
6
 
7
- __version__ = "1.9.12"
7
+ __version__ = "1.9.13"
@@ -6,7 +6,7 @@
6
6
 
7
7
  class FormatParams(object):
8
8
  max_line_length = None
9
- _max_line_lenght_default = 79
9
+ max_line_length_default = 79
10
10
  wrap_paren = True
11
11
  indent = 4
12
12
  hanging_indent = 'never'
@@ -128,11 +128,15 @@ def pyfill(prefix, tokens, params=FormatParams()):
128
128
  :rtype:
129
129
  ``str``
130
130
  """
131
- N = params.max_line_length or params._max_line_lenght_default
131
+ if params.max_line_length is None:
132
+ max_line_length = params.max_line_length_default
133
+ else:
134
+ max_line_length = params.max_line_length
135
+
132
136
  if params.wrap_paren:
133
137
  # Check how we will break up the tokens.
134
138
  len_full = sum(len(tok) for tok in tokens) + 2 * (len(tokens)-1)
135
- if len(prefix) + len_full <= N:
139
+ if len(prefix) + len_full <= max_line_length:
136
140
  # The entire thing fits on one line; no parens needed. We check
137
141
  # this first because breaking into lines adds paren overhead.
138
142
  #
@@ -153,7 +157,7 @@ def pyfill(prefix, tokens, params=FormatParams()):
153
157
  # longest token since even if the first token fits, we still want
154
158
  # to avoid later tokens running over N.
155
159
  maxtoklen = max(len(token) for token in tokens)
156
- hanging_indent = (len(prefix) + maxtoklen + 2 > N)
160
+ hanging_indent = (len(prefix) + maxtoklen + 2 > max_line_length)
157
161
  else:
158
162
  raise ValueError("bad params.hanging_indent=%r"
159
163
  % (params.hanging_indent,))
@@ -166,7 +170,7 @@ def pyfill(prefix, tokens, params=FormatParams()):
166
170
  # abc, defgh, ijkl,
167
171
  # mnopq, rst)
168
172
  return (prefix + "(\n"
169
- + fill(tokens, max_line_length=N,
173
+ + fill(tokens, max_line_length=max_line_length,
170
174
  prefix=(" " * params.indent), suffix=("", ")")))
171
175
  else:
172
176
  # Non-hanging-indent mode.
@@ -176,7 +180,7 @@ def pyfill(prefix, tokens, params=FormatParams()):
176
180
  # ijkl, mnopq,
177
181
  # rst)
178
182
  pprefix = prefix + "("
179
- return fill(tokens, max_line_length=N,
183
+ return fill(tokens, max_line_length=max_line_length,
180
184
  prefix=(pprefix, " " * len(pprefix)), suffix=("", ")"))
181
185
  else:
182
186
  raise NotImplementedError
@@ -512,7 +512,7 @@ class ImportStatement:
512
512
 
513
513
  return tuple(self.aliases[0][0].split('.'))
514
514
 
515
-
515
+
516
516
  def _cmp(self):
517
517
  """
518
518
  Comparison function for sorting.
@@ -587,12 +587,12 @@ class ImportStatement:
587
587
 
588
588
  black_config = read_black_config()
589
589
  mode = dict()
590
- if "line_length" in black_config:
591
- mode["line_length"] = (
592
- params.max_line_length
593
- if params.max_line_length
594
- else black_config["line_length"]
595
- )
590
+
591
+ if params.max_line_length is None:
592
+ mode["line_length"] = black_config.get("line_length", params.max_line_length_default)
593
+ else:
594
+ mode["line_length"] = params.max_line_length
595
+
596
596
  if "target_version" in black_config:
597
597
  if isinstance(black_config["target_version"], set):
598
598
  target_versions_in = black_config["target_version"]
@@ -4,4 +4,4 @@
4
4
  # http://creativecommons.org/publicdomain/zero/1.0/
5
5
 
6
6
 
7
- __version__ = "1.9.12"
7
+ __version__ = "1.9.13"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyflyby
3
- Version: 1.9.12
3
+ Version: 1.9.13
4
4
  Summary: pyflyby - Python development productivity tools, in particular automatic import management
5
5
  Home-page: https://pypi.org/project/pyflyby/
6
6
  Author: Karl Chen
@@ -11,6 +11,7 @@ import sys
11
11
  from textwrap import dedent
12
12
  import types
13
13
 
14
+ from pyflyby._format import FormatParams
14
15
  from pyflyby._importdb import ImportDB
15
16
  from pyflyby._imports2s import (canonicalize_imports,
16
17
  fix_unused_and_missing_imports,
@@ -1111,3 +1112,50 @@ def test_fix_unused_imports_submodule_importas_1():
1111
1112
  m2.x + m2y + m3.x
1112
1113
  '''))
1113
1114
  assert expected == output
1115
+
1116
+
1117
+ def test_reformat_import_statements_respect_width_1(tmp_path):
1118
+ """Test that tidy-imports with a max line length correctly wraps imports."""
1119
+ filename = str(tmp_path / "test_reformat_import_statements_respect_width_1")
1120
+ input = PythonBlock(dedent('''
1121
+ from math import sin,cos,tan,sinh,cosh,tanh,log,floor,log10,remainder,factorial,nextafter,radians
1122
+ assert [sin,cos,tan,sinh,cosh,tanh,log,floor,log10,remainder,factorial,nextafter,radians]
1123
+ ''').lstrip(), filename=filename)
1124
+ output = reformat_import_statements(input, FormatParams(max_line_length=100))
1125
+ expected = PythonBlock(dedent('''
1126
+ from math import (cos, cosh, factorial, floor, log, log10, nextafter, radians, remainder, sin, sinh,
1127
+ tan, tanh)
1128
+ assert [sin,cos,tan,sinh,cosh,tanh,log,floor,log10,remainder,factorial,nextafter,radians]
1129
+ ''').lstrip(), filename=filename)
1130
+ assert output == expected
1131
+
1132
+
1133
+ def test_reformat_import_statements_respect_width_2(tmp_path):
1134
+ """Test that tidy-imports with a max line length correctly wraps imports."""
1135
+ filename = str(tmp_path / "test_reformat_import_statements_respect_width_2")
1136
+ input = PythonBlock(dedent('''
1137
+ from math import sin,cos,tan,sinh,cosh,tanh,log,floor,log10,remainder,factorial,nextafter,radians
1138
+ assert [sin,cos,tan,sinh,cosh,tanh,log,floor,log10,remainder,factorial,nextafter,radians]
1139
+ ''').lstrip(), filename=filename)
1140
+ output = reformat_import_statements(input, FormatParams(max_line_length=200))
1141
+ expected = PythonBlock(dedent('''
1142
+ from math import cos, cosh, factorial, floor, log, log10, nextafter, radians, remainder, sin, sinh, tan, tanh
1143
+ assert [sin,cos,tan,sinh,cosh,tanh,log,floor,log10,remainder,factorial,nextafter,radians]
1144
+ ''').lstrip(), filename=filename)
1145
+ assert output == expected
1146
+
1147
+
1148
+ def test_reformat_import_statements_respect_width_3(tmp_path):
1149
+ """Test that tidy-imports with no specified width matches the default width."""
1150
+ filename = str(tmp_path / "test_reformat_import_statements_respect_width_3")
1151
+ input = PythonBlock(dedent('''
1152
+ from math import sin,cos,tan,sinh,cosh,tanh,log,floor,log10,remainder,factorial,nextafter,radians
1153
+ assert [sin,cos,tan,sinh,cosh,tanh,log,floor,log10,remainder,factorial,nextafter,radians]
1154
+ ''').lstrip(), filename=filename)
1155
+ assert reformat_import_statements(
1156
+ input,
1157
+ FormatParams(max_line_length=None),
1158
+ ) == reformat_import_statements(
1159
+ input,
1160
+ FormatParams(max_line_length=FormatParams.max_line_length_default),
1161
+ )
@@ -123,11 +123,34 @@ def test_Import_replace_2():
123
123
 
124
124
  @patch("pyflyby._importstmt.read_black_config", lambda: {"line_length": 20})
125
125
  def test_Import_black_line_length():
126
+ """Test that a black config takes precedence over the default line length."""
126
127
  stmt = Import("from a123456789 import b123456789")
127
128
  result = stmt.pretty_print(params=FormatParams(use_black=True))
128
129
  assert result == "from a123456789 import (\n b123456789,\n)\n"
129
130
 
130
131
 
132
+ @patch("pyflyby._importstmt.read_black_config", lambda: {})
133
+ def test_Import_black_line_length2():
134
+ """Test that the default line length is used if no black config is present."""
135
+ stmt = Import("from math import sincostansinhcoshtanhlogfloorlog10remainderfactorialnextafter")
136
+ result = stmt.pretty_print(params=FormatParams(use_black=True))
137
+ assert result == "from math import sincostansinhcoshtanhlogfloorlog10remainderfactorialnextafter\n"
138
+
139
+ @patch("pyflyby._importstmt.read_black_config", lambda: {})
140
+ def test_Import_black_line_length3():
141
+ """Test that the default line length is used if no black config is present."""
142
+ stmt = Import("from math import sincostansinhcoshtanhlogfloorlog10remainderfactorialnextafterradians")
143
+ result = stmt.pretty_print(params=FormatParams(use_black=True))
144
+ assert result == "from math import (\n sincostansinhcoshtanhlogfloorlog10remainderfactorialnextafterradians,\n)\n"
145
+
146
+ @patch("pyflyby._importstmt.read_black_config", lambda: {"line_length": 200})
147
+ def test_Import_black_line_length4():
148
+ """Test that a command line --width takes precedence over a black config."""
149
+ stmt = Import("from a123456789 import b123456789")
150
+ result = stmt.pretty_print(params=FormatParams(use_black=True, max_line_length=20))
151
+ assert result == "from a123456789 import (\n b123456789,\n)\n"
152
+
153
+
131
154
  def test_ImportStatement_1():
132
155
  stmt = ImportStatement("import foo . bar")
133
156
  assert stmt.fromname == None
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes