<blockquote>
<p dir="auto">Describe how to replicate the bug.</p>
</blockquote>
<p dir="auto">I'm doing the fairly standard thing of adding a <code class="notranslate">g.user</code> property on the appcontext in my app, but <code class="notranslate">pylint</code> is complaining with:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Assigning to attribute 'user' not defined in class slots (assigning-non-slot)"><pre class="notranslate"><code class="notranslate">Assigning to attribute 'user' not defined in class slots (assigning-non-slot)
</code></pre></div>
<p dir="auto">Ignoring the pylint warning makes mypy complain very loudly error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&quot;AppContext&quot; has no attribute &quot;user&quot;"><pre class="notranslate"><code class="notranslate">"AppContext" has no attribute "user"
</code></pre></div>
<p dir="auto">This can be reproduced using the docs <a href="https://flask.palletsprojects.com/en/2.0.x/appcontext/#storing-data" rel="nofollow">https://flask.palletsprojects.com/en/2.0.x/appcontext/#storing-data</a>, which tell the user to store the <code class="notranslate">db</code> on <code class="notranslate">g</code> using: <code class="notranslate">g.db = connect_to_database()</code>.</p>
<p dir="auto">If we're not supposed to be setting random properties there any more then the docs probably need fixing. maybe we're supposed to use <code class="notranslate">db = g.setdefault("db", connect_to_database())</code> now?</p>
<ul dir="auto">
<li>Python version: <code class="notranslate">2.0.0</code></li>
<li>Flask version: <code class="notranslate">3.9.4</code></li>
</ul>
<p dir="auto">Thanks for a recent release of <code class="notranslate">flask</code> which looks great. <g-emoji class="g-emoji" alias="tada" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f389.png">🎉</g-emoji> Just started testing it out.</p>
<p dir="auto">This is not directly a bug afaik, but our CI started failing on the new release of <code class="notranslate">flask</code> and <code class="notranslate">werkzeug</code>.</p>
<p dir="auto">Following the flask documentation, it appears the recommended way of setting new attributes to <code class="notranslate">flask.g</code> is simply doing <code class="notranslate">flask.g.some_attribute = some_value</code>.</p>
<p dir="auto">This example code</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from flask import g

g.some_attribute = 42"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">flask</span> <span class="pl-k">import</span> <span class="pl-s1">g</span>

<span class="pl-s1">g</span>.<span class="pl-s1">some_attribute</span> <span class="pl-c1">=</span> <span class="pl-c1">42</span></pre></div>
<p dir="auto">gives no <code class="notranslate">pylint</code> warning when used together with <code class="notranslate">pip install "flask&lt;2" "werkzeug&lt;2"</code>, however after <code class="notranslate">pip install --upgrade flask werkzeug</code> the same code gives the following <code class="notranslate">pylint</code> warning:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="test_pylint.py:3:0: E0237: Assigning to attribute 'some_attribute' not defined in class slots (assigning-non-slot)"><pre class="notranslate"><code class="notranslate">test_pylint.py:3:0: E0237: Assigning to attribute 'some_attribute' not defined in class slots (assigning-non-slot)
</code></pre></div>
<p dir="auto">Any recommended code change that should be done related to setting attributes on the namespace object <code class="notranslate">flask.g</code>, or would the best recommendation be to silence <code class="notranslate">pylint</code> when used with newest <code class="notranslate">flask</code> + <code class="notranslate">werkzeug</code>?</p>