]> git.madduck.net Git - etc/vim.git/blob - docs/faq.md

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Mark Felix and Batuhan as maintainers (#2794)
[etc/vim.git] / docs / faq.md
1 # Frequently Asked Questions
2
3 The most common questions and issues users face are aggregated to this FAQ.
4
5 ```{contents}
6 :local:
7 :backlinks: none
8 :class: this-will-duplicate-information-and-it-is-still-useful-here
9 ```
10
11 ## Does Black have an API?
12
13 Not yet. _Black_ is fundamentally a command line tool. Many
14 [integrations](integrations/index.rst) are provided, but a Python interface is not one
15 of them. A simple API is being [planned](https://github.com/psf/black/issues/779)
16 though.
17
18 ## Is Black safe to use?
19
20 Yes, for the most part. _Black_ is strictly about formatting, nothing else. But because
21 _Black_ is still in [beta](index.rst), some edges are still a bit rough. To combat
22 issues, the equivalence of code after formatting is
23 [checked](the_black_code_style/current_style.md#ast-before-and-after-formatting) with
24 limited special cases where the code is allowed to differ. If issues are found, an error
25 is raised and the file is left untouched. Magical comments that influence linters and
26 other tools, such as `# noqa`, may be moved by _Black_. See below for more details.
27
28 ## How stable is Black's style?
29
30 Quite stable. _Black_ aims to enforce one style and one style only, with some room for
31 pragmatism. However, _Black_ is still in beta so style changes are both planned and
32 still proposed on the issue tracker. See
33 [The Black Code Style](the_black_code_style/index.rst) for more details.
34
35 Starting in 2022, the formatting output will be stable for the releases made in the same
36 year (other than unintentional bugs). It is possible to opt-in to the latest formatting
37 styles, using the `--preview` flag.
38
39 ## Why is my file not formatted?
40
41 Most likely because it is ignored in `.gitignore` or excluded with configuration. See
42 [file collection and discovery](usage_and_configuration/file_collection_and_discovery.md)
43 for details.
44
45 ## Why is my Jupyter Notebook cell not formatted?
46
47 _Black_ is timid about formatting Jupyter Notebooks. Cells containing any of the
48 following will not be formatted:
49
50 - automagics (e.g. `pip install black`)
51 - non-Python cell magics (e.g. `%%writeline`)
52 - multiline magics, e.g.:
53
54   ```python
55   %timeit f(1, \
56           2, \
57           3)
58   ```
59
60 - code which `IPython`'s `TransformerManager` would transform magics into, e.g.:
61
62   ```python
63   get_ipython().system('ls')
64   ```
65
66 - invalid syntax, as it can't be safely distinguished from automagics in the absence of
67   a running `IPython` kernel.
68
69 ## Why are Flake8's E203 and W503 violated?
70
71 Because they go against PEP 8. E203 falsely triggers on list
72 [slices](the_black_code_style/current_style.md#slices), and adhering to W503 hinders
73 readability because operators are misaligned. Disable W503 and enable the
74 disabled-by-default counterpart W504. E203 should be disabled while changes are still
75 [discussed](https://github.com/PyCQA/pycodestyle/issues/373).
76
77 ## Does Black support Python 2?
78
79 Support for formatting Python 2 code was removed in version 22.0.
80
81 ## Why does my linter or typechecker complain after I format my code?
82
83 Some linters and other tools use magical comments (e.g., `# noqa`, `# type: ignore`) to
84 influence their behavior. While Black does its best to recognize such comments and leave
85 them in the right place, this detection is not and cannot be perfect. Therefore, you'll
86 sometimes have to manually move these comments to the right place after you format your
87 codebase with _Black_.
88
89 ## Can I run Black with PyPy?
90
91 Yes, there is support for PyPy 3.7 and higher.
92
93 ## Why does Black not detect syntax errors in my code?
94
95 _Black_ is an autoformatter, not a Python linter or interpreter. Detecting all syntax
96 errors is not a goal. It can format all code accepted by CPython (if you find an example
97 where that doesn't hold, please report a bug!), but it may also format some code that
98 CPython doesn't accept.