|
| 1 | +Troubleshooting |
| 2 | +=============== |
| 3 | + |
| 4 | + |
| 5 | +Formatting still fails after running ``project:fix`` |
| 6 | +---------------------------------------------------- |
| 7 | + |
| 8 | +If when you execute: |
| 9 | + |
| 10 | +#. Run ``project:fix`` |
| 11 | +#. Run ``project:format`` |
| 12 | + |
| 13 | +you receive an error from ``project:format`` (i.e. ``isort`` or ``black``), it it |
| 14 | +likely that you need to update your configuration to align with :ref:formatting_code. |
| 15 | +# TODO REFERENCE |
| 16 | + |
| 17 | +The automatic formatting is doing x, but we shouldn't do that because of y |
| 18 | +--------------------------------------------------------------------------- |
| 19 | +Usually, automatic formatting is helpful, but there are rare cases where a developer |
| 20 | +might want to ignore automatically applied formatting. |
| 21 | + |
| 22 | +.. note:: |
| 23 | + To ensure that automatic formatting remains useful, developers should always seek |
| 24 | + to use the minimum fix reasonable for the affected code. In most cases, this would |
| 25 | + mean adding a comment for a single line. |
| 26 | + |
| 27 | ++-----------------------+--------------------------------+-----------------------+ |
| 28 | +| Undesired Action | Single line | Within a file | |
| 29 | ++=======================+================================+=======================+ |
| 30 | +| formatting from black | .. code-block:: python | |
| 31 | +| | | |
| 32 | +| | # fmt: off | |
| 33 | +| | <code being ignored by black> | |
| 34 | +| | # fmt: on | |
| 35 | ++-----------------------+--------------------------------+-----------------------+ |
| 36 | +| formatting from isort | .. code-block:: python | .. code-block:: python| |
| 37 | +| | | | |
| 38 | +| | <line-to-ignore> # isort:skip| # isort:skip_file | |
| 39 | ++-----------------------+--------------------------------+-----------------------+ |
| 40 | + |
| 41 | + |
| 42 | +In the ``checks.yml``, ``project:format`` wants me to reformat code I did not modify |
| 43 | +------------------------------------------------------------------------------------ |
| 44 | + |
| 45 | +This is likely due to one of our tools (i.e. `black`) being upgraded. Within the |
| 46 | +`pyproject.toml` of the PTB, dependencies are specified to allow |
| 47 | +compatible versions or a restricted version range (i.e., `^6.0.1`, `>=24.1.0,<26.0.0`). |
| 48 | +Such specifications should restrict major reformatting changes to coincide only with a |
| 49 | +new major version of the PTB. However, sometimes a tool's versioning may not properly |
| 50 | +adhere to semantic versioning. |
| 51 | + |
| 52 | +If you encounter this scenario, please: |
| 53 | + |
| 54 | +#. Ensure that your `pyproject.toml` has the PTB restricted to compatible versions |
| 55 | + (i.e., `^1.7.0`). |
| 56 | +#. Identify which tool is trying to reformat files that you did not modify. |
| 57 | +#. Reset your `poetry.lock` to align with what's in the project's **default branch**. |
| 58 | +#. More selectively update your `poetry.lock` with `poetry update <package-name>`. |
| 59 | +#. Share with your team which tool & version led to the unexpected changes. So that |
| 60 | + other PTB users do not experience the same difficulties, we will update the PTB with |
| 61 | + a patch version to avoid this tool's version and later do a major release to better |
| 62 | + indicate the breaking changes. You could later create an issue in your GitHub |
| 63 | + repository to update to the new major version of the PTB & do the reformatting. |
0 commit comments