question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Having settings located in pyproject.toml doesn't work correctly

See original GitHub issue

Hi, I have config located in a pyproject.toml file as described here: https://mypy.readthedocs.io/en/stable/config_file.html?highlight=pyproject.toml#using-a-pyproject-toml-file

This does not get automatically detected by this hook, but I can force it to look there by making the hook look as follows:

    - repo: https://github.com/pre-commit/mirrors-mypy
      # Type checks
      rev: "" # Use the sha / tag you want to point at
      hooks:
          - id: mypy
            args: [--config-file=pyproject.toml]

And while this does work with very basic toml files it breaks once one of your tools uses multiline strings… So with the following config pre-commit will fail:

[tool.black]
line-length = 119
target-version = ['py38']
include = '\.pyi?$'
exclude = '''
/(
    \.eggs
  | \.git
  | \.hg
  | \.mypy_cache
  | \.tox
  | \.venv
  | _build
  | buck-out
  | build
  | dist
  # The following are specific to Black, you probably don't want those.
  | blib2to3
  | tests/data
  | profiling
)/
'''

[tool.isort]
known_first_party = ["paperbag", "gels_and_blots"]
profile = "black"
filter_files = true

[mypy]
python_version = 3.8
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
ignore_missing_imports = true

Error message:

mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

pyproject.toml: Source contains parsing errors: 'pyproject.toml'
	[line  6]: '/(\n'
	[line 21]: ')/\n'
	[line 22]: "'''\n"

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
RonnyPfannschmidtcommented, Dec 18, 2022

@asottile im observing this with the most recent mirrors-mypy, i’l tr to debug this week

0reactions
asottilecommented, Dec 19, 2022

yep, figured as much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] unable to do a local install with pyproject.toml in a venv ...
Local installation of the package doesn't work in the venv, created with ... cat -n xxx/pyproject.toml 1 [build-system] 2 requires ...
Read more >
What is pyproject.toml file for? - python - Stack Overflow
Yes, pyproject.toml is the specified file format of PEP 518 which contains the build system requirements of Python projects. This solves the build-tool ......
Read more >
Understanding setup.py, setup.cfg and pyproject.toml in Python
This blog post is designed to clarify my thinking around installing Python packages and the use of setup.py, setup.cfg and pyproject.toml ...
Read more >
Configuring setuptools using pyproject.toml files
The example below illustrates how to write a pyproject. toml file that can be used with setuptools .
Read more >
A Practical Guide to Setuptools and Pyproject.toml
An example driven guide to setting up and building a python package using Setuptools together with pyproject.toml.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found