Repository: jgosmann/pylint-venv (language: python)

Issue:
config for pyproject.toml
This is what is working for me:

```toml
[tool.pylint.main]
init-hook ="""
try:
  import pylint_venv
except ImportError:
  pass
else:
  pylint_venv.inithook()
"""
```

The config in readme does not work due to parsing issues. Test on pylint 2.17.2
config for pyproject.toml
This is what is working for me:

```toml
[tool.pylint.main]
init-hook ="""
try:
  import pylint_venv
except ImportError:
  pass
else:
  pylint_venv.inithook()
"""
```

The config in readme does not work due to parsing issues. Test on pylint 2.17.2


Discussion / hints:
The config in the README is intended for the `.pylintrc` file, not `pyproject.toml`. Did you verify that there is indeed a problem with the given `.pylintrc` config independent of configuration via `pyproject.toml`?
> This is what is working for me:

Thanks jdhao, this worked for me as well.

> The config in the README is intended for the .pylintrc file, not pyproject.toml.

Maybe classifying this issue as a documentation request (rather then a parsing error) is the way to go? I'm not sure how ubiquitous pyproject.toml is becoming elsewhere, but I am using it on new projects. I appreciate that I could cut & paste the code provided rather then having to translate .pylintrc to .toml - I don't work with .pylintrc very often. It would be better if I was cutting and pasting from an official source instead of an issue report. imho.
@Ash8888 fair point, would you be willing to prepare a PR?
The config in the README is intended for the `.pylintrc` file, not `pyproject.toml`. Did you verify that there is indeed a problem with the given `.pylintrc` config independent of configuration via `pyproject.toml`?
> This is what is working for me:

Thanks jdhao, this worked for me as well.

> The config in the README is intended for the .pylintrc file, not pyproject.toml.

Maybe classifying this issue as a documentation request (rather then a parsing error) is the way to go? I'm not sure how ubiquitous pyproject.toml is becoming elsewhere, but I am using it on new projects. I appreciate that I could cut & paste the code provided rather then having to translate .pylintrc to .toml - I don't work with .pylintrc very often. It would be better if I was cutting and pasting from an official source instead of an issue report. imho.
@Ash8888 fair point, would you be willing to prepare a PR?

Fix patch:
diff --git a/CHANGES.md b/CHANGES.md
index 6c8b1eb..ac1a853 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 - Official support for Pylint 3.
 - Official support for Python 3.12.
+- Documentation for configuration within `pyproject.toml`
+  ([#17](https://github.com/jgosmann/pylint-venv/issues/17),
+  [#19](https://github.com/jgosmann/pylint-venv/pull/19)).
 
 
 ## [3.0.2] - 2023-06-12
diff --git a/README.rst b/README.rst
index 949d29e..574cd76 100644
--- a/README.rst
+++ b/README.rst
@@ -12,8 +12,29 @@ Installation
 .. code:: bash
 
     pip install pylint-venv
+    
+Add the hook to your Pylint configuration. See the section below corresponding
+to the type of configuration file you use.
 
-Add the following to your ``~/.pylintrc``:
+Configure with ``pyproject.toml``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Add the following to your ``pyproject.toml``:
+
+.. code:: toml
+   
+    [tool.pylint.MAIN]
+    init-hook = """
+    try: import pylint_venv
+    except ImportError: pass
+    else: pylint_venv.inithook()
+    """
+
+
+Configure with ``.pylintrc``
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Add the following to your ``.pylintrc``:
 
 .. code:: ini
 
@@ -22,6 +43,13 @@ Add the following to your ``~/.pylintrc``:
         try: import pylint_venv
         except ImportError: pass
         else: pylint_venv.inithook()
+        
+If you add this to your ``~/.pylintrc`` in your home directory, it will be
+applied to all projects by default.
+
+        
+Usage
+-----
 
 The hook will then be used automatically if
 


Test patch:
diff --git a/test/pyproject.toml b/test/pyproject.toml
new file mode 100644
index 0000000..15bcc55
--- /dev/null
+++ b/test/pyproject.toml
@@ -0,0 +1,5 @@
+[tool.pylint.MAIN]
+init-hook = """
+import pylint_venv
+pylint_venv.inithook(force_venv_activation=True)
+"""
diff --git a/test/test.sh b/test/test.sh
index 1feecdb..10a1165 100755
--- a/test/test.sh
+++ b/test/test.sh
@@ -8,4 +8,5 @@ VENV_DIR=$(mktemp -d)
 python3 -m venv "$VENV_DIR"
 source "$VENV_DIR/bin/activate"
 pylint --rcfile "$WORKDIR/pylintrc" "$WORKDIR/empty.py" 2>&1 | tee "$VENV_DIR/pylint.log" | grep "^Using venv: $VENV_DIR\$"
+pylint --rcfile "$WORKDIR/pyproject.toml" "$WORKDIR/empty.py" 2>&1 | tee "$VENV_DIR/pylint.log" | grep "^Using venv: $VENV_DIR\$"
 rm -r "$VENV_DIR"