flake8-async 25.2.2__tar.gz → 25.2.3__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.
Files changed (142) hide show
  1. {flake8_async-25.2.2 → flake8_async-25.2.3}/PKG-INFO +4 -2
  2. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/__init__.py +37 -4
  3. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async.egg-info/PKG-INFO +4 -2
  4. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async.egg-info/requires.txt +3 -1
  5. {flake8_async-25.2.2 → flake8_async-25.2.3}/setup.py +2 -1
  6. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async119.py +1 -1
  7. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/test_config_and_args.py +39 -2
  8. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/test_decorator.py +24 -9
  9. {flake8_async-25.2.2 → flake8_async-25.2.3}/tox.ini +1 -1
  10. {flake8_async-25.2.2 → flake8_async-25.2.3}/CHANGELOG.md +0 -0
  11. {flake8_async-25.2.2 → flake8_async-25.2.3}/CONTRIBUTING.md +0 -0
  12. {flake8_async-25.2.2 → flake8_async-25.2.3}/LICENSE +0 -0
  13. {flake8_async-25.2.2 → flake8_async-25.2.3}/MANIFEST.in +0 -0
  14. {flake8_async-25.2.2 → flake8_async-25.2.3}/README.md +0 -0
  15. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/__main__.py +0 -0
  16. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/base.py +0 -0
  17. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/runner.py +0 -0
  18. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/visitors/__init__.py +0 -0
  19. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/visitors/flake8asyncvisitor.py +0 -0
  20. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/visitors/helpers.py +0 -0
  21. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/visitors/visitor101.py +0 -0
  22. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/visitors/visitor102_120.py +0 -0
  23. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/visitors/visitor103_104.py +0 -0
  24. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/visitors/visitor105.py +0 -0
  25. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/visitors/visitor111.py +0 -0
  26. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/visitors/visitor118.py +0 -0
  27. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/visitors/visitor123.py +0 -0
  28. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/visitors/visitor2xx.py +0 -0
  29. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/visitors/visitor91x.py +0 -0
  30. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/visitors/visitor_utility.py +0 -0
  31. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async/visitors/visitors.py +0 -0
  32. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async.egg-info/SOURCES.txt +0 -0
  33. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async.egg-info/dependency_links.txt +0 -0
  34. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async.egg-info/entry_points.txt +0 -0
  35. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async.egg-info/not-zip-safe +0 -0
  36. {flake8_async-25.2.2 → flake8_async-25.2.3}/flake8_async.egg-info/top_level.txt +0 -0
  37. {flake8_async-25.2.2 → flake8_async-25.2.3}/pyproject.toml +0 -0
  38. {flake8_async-25.2.2 → flake8_async-25.2.3}/setup.cfg +0 -0
  39. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/__init__.py +0 -0
  40. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/autofix_files/async100.py +0 -0
  41. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/autofix_files/async100_asyncio.py +0 -0
  42. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/autofix_files/async100_simple_autofix.py +0 -0
  43. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/autofix_files/async124.py +0 -0
  44. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/autofix_files/async910.py +0 -0
  45. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/autofix_files/async910_insert_library.py +0 -0
  46. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/autofix_files/async911.py +0 -0
  47. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/autofix_files/async911_insert_library.py +0 -0
  48. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/autofix_files/async913.py +0 -0
  49. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/autofix_files/async913_trio_anyio.py +0 -0
  50. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/autofix_files/async91x_autofix.py +0 -0
  51. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/autofix_files/exception_suppress_context_manager.py +0 -0
  52. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/autofix_files/exception_suppress_context_manager_import_star.py +0 -0
  53. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/autofix_files/noqa.py +0 -0
  54. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/autofix_files/noqa_testing.py +0 -0
  55. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/check_changelog_and_version.py +0 -0
  56. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/conftest.py +0 -0
  57. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/anyio_trio.py +0 -0
  58. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async100.py +0 -0
  59. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async100_asyncio.py +0 -0
  60. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async100_noautofix.py +0 -0
  61. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async100_simple_autofix.py +0 -0
  62. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async101.py +0 -0
  63. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async101_asyncio.py +0 -0
  64. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async102.py +0 -0
  65. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async102_aclose.py +0 -0
  66. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async102_aclose_args.py +0 -0
  67. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async102_anyio.py +0 -0
  68. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async102_asyncio.py +0 -0
  69. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async102_trio.py +0 -0
  70. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async103.py +0 -0
  71. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async103_all_imported.py +0 -0
  72. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async103_both_imported.py +0 -0
  73. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async103_no_104.py +0 -0
  74. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async103_trio.py +0 -0
  75. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async104.py +0 -0
  76. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async104_anyio.py +0 -0
  77. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async104_trio.py +0 -0
  78. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async105.py +0 -0
  79. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async105_anyio.py +0 -0
  80. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async106.py +0 -0
  81. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async109.py +0 -0
  82. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async110.py +0 -0
  83. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async111.py +0 -0
  84. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async111_asyncio.py +0 -0
  85. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async112.py +0 -0
  86. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async112_asyncio.py +0 -0
  87. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async113.py +0 -0
  88. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async113_asyncio.py +0 -0
  89. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async113_trio.py +0 -0
  90. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async114.py +0 -0
  91. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async115.py +0 -0
  92. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async116.py +0 -0
  93. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async118.py +0 -0
  94. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async120.py +0 -0
  95. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async121.py +0 -0
  96. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async121_anyio.py +0 -0
  97. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async121_asyncio.py +0 -0
  98. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async122.py +0 -0
  99. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async123.py +0 -0
  100. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async123_py311.py +0 -0
  101. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async124.py +0 -0
  102. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async124_no_autofix.py +0 -0
  103. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async200.py +0 -0
  104. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async210.py +0 -0
  105. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async211.py +0 -0
  106. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async212.py +0 -0
  107. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async22x.py +0 -0
  108. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async22x_asyncio.py +0 -0
  109. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async232.py +0 -0
  110. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async232_asyncio.py +0 -0
  111. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async23x.py +0 -0
  112. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async23x_asyncio.py +0 -0
  113. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async240.py +0 -0
  114. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async250.py +0 -0
  115. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async250_multi_library.py +0 -0
  116. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async251.py +0 -0
  117. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async251_multi_library.py +0 -0
  118. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async300.py +0 -0
  119. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async900.py +0 -0
  120. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async910.py +0 -0
  121. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async910_insert_library.py +0 -0
  122. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async911.py +0 -0
  123. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async911_insert_library.py +0 -0
  124. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async912.py +0 -0
  125. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async912_asyncio.py +0 -0
  126. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async913.py +0 -0
  127. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async913_trio_anyio.py +0 -0
  128. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async91x_autofix.py +0 -0
  129. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/async91x_noautofix.py +0 -0
  130. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/exception_suppress_context_manager.py +0 -0
  131. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/exception_suppress_context_manager_import_star.py +0 -0
  132. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/no_library.py +0 -0
  133. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/noqa.py +0 -0
  134. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/noqa_no_autofix.py +0 -0
  135. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/noqa_testing.py +0 -0
  136. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/eval_files/trio_anyio.py +0 -0
  137. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/test_all_visitors_imported.py +0 -0
  138. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/test_exception_on_invalid_code.py +0 -0
  139. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/test_flake8_async.py +0 -0
  140. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/test_formatting.py +0 -0
  141. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/test_messages_documented.py +0 -0
  142. {flake8_async-25.2.2 → flake8_async-25.2.3}/tests/trio_options.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: flake8-async
3
- Version: 25.2.2
3
+ Version: 25.2.3
4
4
  Summary: A highly opinionated flake8 plugin for Trio-related problems.
5
5
  Author: Zac Hatfield-Dodds, John Litborn, and Contributors
6
6
  Author-email: zac@zhd.dev
@@ -21,8 +21,9 @@ Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Programming Language :: Python :: 3.13
22
22
  Requires-Python: >=3.9
23
23
  Description-Content-Type: text/markdown
24
- Requires-Dist: flake8>=6
25
24
  Requires-Dist: libcst>=1.0.1
25
+ Provides-Extra: flake8
26
+ Requires-Dist: flake8>=6; extra == "flake8"
26
27
  Dynamic: author
27
28
  Dynamic: author-email
28
29
  Dynamic: classifier
@@ -30,6 +31,7 @@ Dynamic: description
30
31
  Dynamic: description-content-type
31
32
  Dynamic: license
32
33
  Dynamic: project-url
34
+ Dynamic: provides-extra
33
35
  Dynamic: requires-dist
34
36
  Dynamic: requires-python
35
37
  Dynamic: summary
@@ -38,7 +38,7 @@ if TYPE_CHECKING:
38
38
 
39
39
 
40
40
  # CalVer: YY.month.patch, e.g. first release of July 2022 == "22.7.1"
41
- __version__ = "25.2.2"
41
+ __version__ = "25.2.3"
42
42
 
43
43
 
44
44
  # taken from https://github.com/Zac-HD/shed
@@ -127,8 +127,11 @@ class Plugin:
127
127
  assert self._options is not None
128
128
  return self._options
129
129
 
130
- def __init__(self, tree: ast.AST, lines: Sequence[str]):
130
+ def __init__(
131
+ self, tree: ast.AST, lines: Sequence[str], filename: str | None = None
132
+ ):
131
133
  super().__init__()
134
+ self.filename: str | None = filename
132
135
  self._tree = tree
133
136
  source = "".join(lines)
134
137
 
@@ -139,14 +142,17 @@ class Plugin:
139
142
  # only used with --runslow
140
143
  with tokenize.open(filename) as f:
141
144
  source = f.read()
142
- return cls.from_source(source)
145
+ return cls.from_source(source, filename=filename)
143
146
 
144
147
  # alternative `__init__` to avoid re-splitting and/or re-joining lines
145
148
  @classmethod
146
- def from_source(cls, source: str) -> Plugin:
149
+ def from_source(
150
+ cls, source: str, filename: str | PathLike[str] | None = None
151
+ ) -> Plugin:
147
152
  plugin = Plugin.__new__(cls)
148
153
  super(Plugin, plugin).__init__()
149
154
  plugin._tree = ast.parse(source)
155
+ plugin.filename = str(filename) if filename else None
150
156
  plugin.module = cst_parse_module_native(source)
151
157
  return plugin
152
158
 
@@ -231,6 +237,13 @@ class Plugin:
231
237
  " errors."
232
238
  ),
233
239
  )
240
+ add_argument(
241
+ "--per-file-disable",
242
+ type=parse_per_file_disable,
243
+ default={},
244
+ required=False,
245
+ help=("..."),
246
+ )
234
247
  add_argument(
235
248
  "--autofix",
236
249
  type=comma_separated_list,
@@ -441,3 +454,23 @@ def parse_async200_dict(raw_value: str) -> dict[str, str]:
441
454
  )
442
455
  res[split_values[0]] = split_values[1]
443
456
  return res
457
+
458
+
459
+ # not run if flake8 is installed
460
+ def parse_per_file_disable( # pragma: no cover
461
+ raw_value: str,
462
+ ) -> dict[str, tuple[str, ...]]:
463
+ res: dict[str, tuple[str, ...]] = {}
464
+ splitter = "->"
465
+ values = [s.strip() for s in raw_value.split(" \t\n") if s.strip()]
466
+ for value in values:
467
+ split_values = list(map(str.strip, value.split(splitter)))
468
+ if len(split_values) != 2:
469
+ # argparse will eat this error message and spit out its own
470
+ # if we raise it as ValueError
471
+ raise ArgumentTypeError(
472
+ f"Invalid number ({len(split_values)-1}) of splitter "
473
+ f"tokens {splitter!r} in {value!r}"
474
+ )
475
+ res[split_values[0]] = tuple(split_values[1].split(","))
476
+ return res
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: flake8-async
3
- Version: 25.2.2
3
+ Version: 25.2.3
4
4
  Summary: A highly opinionated flake8 plugin for Trio-related problems.
5
5
  Author: Zac Hatfield-Dodds, John Litborn, and Contributors
6
6
  Author-email: zac@zhd.dev
@@ -21,8 +21,9 @@ Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Programming Language :: Python :: 3.13
22
22
  Requires-Python: >=3.9
23
23
  Description-Content-Type: text/markdown
24
- Requires-Dist: flake8>=6
25
24
  Requires-Dist: libcst>=1.0.1
25
+ Provides-Extra: flake8
26
+ Requires-Dist: flake8>=6; extra == "flake8"
26
27
  Dynamic: author
27
28
  Dynamic: author-email
28
29
  Dynamic: classifier
@@ -30,6 +31,7 @@ Dynamic: description
30
31
  Dynamic: description-content-type
31
32
  Dynamic: license
32
33
  Dynamic: project-url
34
+ Dynamic: provides-extra
33
35
  Dynamic: requires-dist
34
36
  Dynamic: requires-python
35
37
  Dynamic: summary
@@ -1,2 +1,4 @@
1
- flake8>=6
2
1
  libcst>=1.0.1
2
+
3
+ [flake8]
4
+ flake8>=6
@@ -34,7 +34,8 @@ setup(
34
34
  license_files=[], # https://github.com/pypa/twine/issues/1216
35
35
  description="A highly opinionated flake8 plugin for Trio-related problems.",
36
36
  zip_safe=False,
37
- install_requires=["flake8>=6", "libcst>=1.0.1"],
37
+ install_requires=["libcst>=1.0.1"],
38
+ extras_require={"flake8": ["flake8>=6"]},
38
39
  python_requires=">=3.9",
39
40
  classifiers=[
40
41
  "Development Status :: 3 - Alpha",
@@ -15,7 +15,7 @@ async def async_with():
15
15
  yield # error: 8
16
16
 
17
17
 
18
- async def warn_on_yeach_yield():
18
+ async def warn_on_each_yield():
19
19
  with open(""):
20
20
  yield # error: 8
21
21
  yield # error: 8
@@ -13,6 +13,11 @@ from flake8_async import Plugin, main
13
13
 
14
14
  from .test_flake8_async import initialize_options
15
15
 
16
+ try:
17
+ import flake8
18
+ except ImportError:
19
+ flake8 = None # type: ignore[assignment]
20
+
16
21
  EXAMPLE_PY_TEXT = """import trio
17
22
  with trio.move_on_after(10):
18
23
  ...
@@ -140,7 +145,7 @@ def test_run_100_autofix(
140
145
 
141
146
  def test_114_raises_on_invalid_parameter(capsys: pytest.CaptureFixture[str]):
142
147
  plugin = Plugin(ast.AST(), [])
143
- # flake8 will reraise ArgumentError as SystemExit
148
+ # argparse will reraise ArgumentTypeError as SystemExit
144
149
  for arg in "blah.foo", "foo*", "*":
145
150
  with pytest.raises(SystemExit):
146
151
  initialize_options(plugin, args=[f"--startable-in-context-manager={arg}"])
@@ -159,6 +164,7 @@ def test_200_options(capsys: pytest.CaptureFixture[str]):
159
164
  assert all(word in err for word in (str(i), arg, "->"))
160
165
 
161
166
 
167
+ @pytest.mark.skipif(flake8 is None, reason="flake8 is not installed")
162
168
  def test_anyio_from_config(tmp_path: Path, capsys: pytest.CaptureFixture[str]):
163
169
  assert tmp_path.joinpath(".flake8").write_text(
164
170
  """
@@ -228,6 +234,7 @@ async def foo():
228
234
  )
229
235
 
230
236
 
237
+ @pytest.mark.skipif(flake8 is None, reason="flake8 is not installed")
231
238
  def test_200_from_config_flake8_internals(
232
239
  tmp_path: Path, capsys: pytest.CaptureFixture[str]
233
240
  ):
@@ -254,6 +261,7 @@ def test_200_from_config_flake8_internals(
254
261
  assert err_msg == out
255
262
 
256
263
 
264
+ @pytest.mark.skipif(flake8 is None, reason="flake8 is not installed")
257
265
  def test_200_from_config_subprocess(tmp_path: Path):
258
266
  err_msg = _test_async200_from_config_common(tmp_path)
259
267
  res = subprocess.run(["flake8"], cwd=tmp_path, capture_output=True, check=False)
@@ -262,6 +270,7 @@ def test_200_from_config_subprocess(tmp_path: Path):
262
270
  assert res.stdout == err_msg.encode("ascii")
263
271
 
264
272
 
273
+ @pytest.mark.skipif(flake8 is None, reason="flake8 is not installed")
265
274
  def test_async200_from_config_subprocess(tmp_path: Path):
266
275
  err_msg = _test_async200_from_config_common(tmp_path, code="trio200")
267
276
  res = subprocess.run(["flake8"], cwd=tmp_path, capture_output=True, check=False)
@@ -273,6 +282,7 @@ def test_async200_from_config_subprocess(tmp_path: Path):
273
282
  assert res.stdout == err_msg.encode("ascii")
274
283
 
275
284
 
285
+ @pytest.mark.skipif(flake8 is None, reason="flake8 is not installed")
276
286
  def test_async200_from_config_subprocess_cli_ignore(tmp_path: Path):
277
287
  _ = _test_async200_from_config_common(tmp_path)
278
288
  res = subprocess.run(
@@ -288,6 +298,20 @@ def test_async200_from_config_subprocess_cli_ignore(tmp_path: Path):
288
298
 
289
299
 
290
300
  def test_900_default_off(capsys: pytest.CaptureFixture[str]):
301
+ res = subprocess.run(
302
+ ["flake8-async", "tests/eval_files/async900.py"],
303
+ capture_output=True,
304
+ check=False,
305
+ encoding="utf8",
306
+ )
307
+ assert res.returncode == 1
308
+ assert not res.stderr
309
+ assert "ASYNC124" in res.stdout
310
+ assert "ASYNC900" not in res.stdout
311
+
312
+
313
+ @pytest.mark.skipif(flake8 is None, reason="flake8 is not installed")
314
+ def test_900_default_off_flake8(capsys: pytest.CaptureFixture[str]):
291
315
  from flake8.main.cli import main
292
316
 
293
317
  returnvalue = main(
@@ -303,11 +327,18 @@ def test_900_default_off(capsys: pytest.CaptureFixture[str]):
303
327
 
304
328
 
305
329
  def test_910_can_be_selected(tmp_path: Path):
330
+ """Check if flake8 allows us to --select our 5-letter code.
331
+
332
+ But we can run with --enable regardless.
333
+ """
306
334
  myfile = tmp_path.joinpath("foo.py")
307
335
  myfile.write_text("""async def foo():\n print()""")
308
336
 
337
+ binary = "flake8-async" if flake8 is None else "flake8"
338
+ select_enable = "enable" if flake8 is None else "select"
339
+
309
340
  res = subprocess.run(
310
- ["flake8", "--select=ASYNC910", "foo.py"],
341
+ [binary, f"--{select_enable}=ASYNC910", "foo.py"],
311
342
  cwd=tmp_path,
312
343
  capture_output=True,
313
344
  check=False,
@@ -384,6 +415,7 @@ def test_enable(
384
415
  )
385
416
 
386
417
 
418
+ @pytest.mark.skipif(flake8 is None, reason="flake8 is not installed")
387
419
  def test_flake8_plugin_with_autofix_fails(tmp_path: Path):
388
420
  write_examplepy(tmp_path)
389
421
  res = subprocess.run(
@@ -453,7 +485,9 @@ def test_disable_noqa_ast(
453
485
  )
454
486
 
455
487
 
488
+ @pytest.mark.skipif(flake8 is None, reason="flake8 is not installed")
456
489
  def test_config_select_error_code(tmp_path: Path) -> None:
490
+ # this ... seems to work? I'm confused
457
491
  assert tmp_path.joinpath(".flake8").write_text(
458
492
  """
459
493
  [flake8]
@@ -469,6 +503,7 @@ extend-select = ASYNC100
469
503
 
470
504
 
471
505
  # flake8>=6 enforces three-letter error codes in config
506
+ @pytest.mark.skipif(flake8 is None, reason="flake8 is not installed")
472
507
  def test_config_ignore_error_code(tmp_path: Path) -> None:
473
508
  assert tmp_path.joinpath(".flake8").write_text(
474
509
  """
@@ -490,6 +525,7 @@ ignore = ASYNC100
490
525
 
491
526
 
492
527
  # flake8>=6 enforces three-letter error codes in config
528
+ @pytest.mark.skipif(flake8 is None, reason="flake8 is not installed")
493
529
  def test_config_extend_ignore_error_code(tmp_path: Path) -> None:
494
530
  assert tmp_path.joinpath(".flake8").write_text(
495
531
  """
@@ -511,6 +547,7 @@ extend-ignore = ASYNC100
511
547
  assert res.returncode == 1
512
548
 
513
549
 
550
+ @pytest.mark.skipif(flake8 is None, reason="flake8 is not installed")
514
551
  # but make sure we can disable selected codes
515
552
  def test_config_disable_error_code(tmp_path: Path) -> None:
516
553
  # select ASYNC200 and create file that induces ASYNC200
@@ -3,11 +3,11 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import ast
6
+ import sys
6
7
  from pathlib import Path
7
8
  from typing import TYPE_CHECKING
8
9
 
9
- from flake8.main.application import Application
10
-
10
+ from flake8_async import main
11
11
  from flake8_async.base import Statement
12
12
  from flake8_async.visitors.helpers import fnmatch_qualified_name
13
13
  from flake8_async.visitors.visitor91x import Visitor91X
@@ -90,11 +90,20 @@ def test_pep614():
90
90
 
91
91
 
92
92
  file_path = str(Path(__file__).parent / "trio_options.py")
93
- common_flags = ["--select=ASYNC", file_path]
94
93
 
95
94
 
96
- def test_command_line_1(capfd: pytest.CaptureFixture[str]):
97
- Application().run([*common_flags, "--no-checkpoint-warning-decorators=app.route"])
95
+ def _set_flags(monkeypatch: pytest.MonkeyPatch, *flags: str):
96
+ monkeypatch.setattr(
97
+ sys, "argv", ["./flake8-async", "--enable=ASYNC910", file_path, *flags]
98
+ )
99
+
100
+
101
+ def test_command_line_1(
102
+ capfd: pytest.CaptureFixture[str], monkeypatch: pytest.MonkeyPatch
103
+ ):
104
+ _set_flags(monkeypatch, "--no-checkpoint-warning-decorators=app.route")
105
+ assert main() == 0
106
+
98
107
  assert capfd.readouterr() == ("", "")
99
108
 
100
109
 
@@ -114,11 +123,17 @@ expected_out = (
114
123
  )
115
124
 
116
125
 
117
- def test_command_line_2(capfd: pytest.CaptureFixture[str]):
118
- Application().run([*common_flags, "--no-checkpoint-warning-decorators=app"])
126
+ def test_command_line_2(
127
+ capfd: pytest.CaptureFixture[str], monkeypatch: pytest.MonkeyPatch
128
+ ):
129
+ _set_flags(monkeypatch, "--no-checkpoint-warning-decorators=app")
130
+ assert main() == 1
119
131
  assert capfd.readouterr() == (expected_out, "")
120
132
 
121
133
 
122
- def test_command_line_3(capfd: pytest.CaptureFixture[str]):
123
- Application().run(common_flags)
134
+ def test_command_line_3(
135
+ capfd: pytest.CaptureFixture[str], monkeypatch: pytest.MonkeyPatch
136
+ ):
137
+ _set_flags(monkeypatch)
138
+ assert main() == 1
124
139
  assert capfd.readouterr() == (expected_out, "")
@@ -1,7 +1,7 @@
1
1
  # The test environment and commands
2
2
  [tox]
3
3
  # default environments to run without `-e`
4
- envlist = py{39,310,311,312,313}-{flake8_6,flake8_7}
4
+ envlist = py{39,310,311,312,313}-{flake8_6,flake8_7},noflake8
5
5
 
6
6
  # create a default testenv, whose behaviour will depend on the name it's called with.
7
7
  # for CI you can call with `-e flake8_6,flake8_7` and let the CI handle python version
File without changes
File without changes
File without changes
File without changes