How can I make PyCharm use PyProject.toml when checking if an imported module is listed in the project requirements?

I have written a Python program which imports two modules, `xattr` and `click`. PyCharm displays warning messages on these `import` statements. The warnings say, “Package containing module ‘xattr’ (or 'click') is not listed in the project requirements”. However, I am using a `PyProject.toml` file to manage my requirements. In this file, there is an entry 'dependencies = [ "click>=8.1.8", “xattr>=1.1.4”] '. My understanding is that this lists those modules in the project requirements.

How can I make the part of PyCharm which issues this warning read PyProject.toml to find out about project requirements, and write updated requirements to PyProject.toml, not requirements.txt ?

I suspect that the warning message comes from the “Python Integrated Tools” <https://www.jetbrains.com/help/pycharm/settings-tools-python-integrated-tools.html>. The wording of its field, “Package requirements file”, implies that it works only with `requirements.txt`. I want it to work with `PyProject.toml`. 

In the PyCharm documentation, section “Manage project requirements” <https://www.jetbrains.com/help/pycharm/managing-project-dependencies.html>, it says that PyCharm “provides integration with the major means of dependencies management including the use of requirements.txt and Pipfile” [and PyProject.toml]. However, it does not say how to tell PyCharm, and especially the Python Integrated Tools, which of these means a project is using. 

I would like a project setting which lets me tell PyCharm clearly that I am using PyProject.toml for dependency management, and have PyCharm pass that on to Python Integrated Tools, pipenv, and any other related tools. 

(I am a paying customer of PyCharm, so I have also asked this question to PyCharm support. I am asking the public forum in parallel. If I get an interesting answer from support, I will post it here.)

1

Thank you, Daniil Bogdanov, for the reply. I have upvoted the issue PY-60068 in YouTrack. (For the record, the same Daniil Bogdanov gave the same reply to my PyCharm support question.)

1

请先登录再写评论。