Skip to content

Fix #229: Document constant NONE vs Python's None#255

Merged
robhudson merged 1 commit intomainfrom
229-doc-NONE-vs-None
Jan 20, 2025
Merged

Fix #229: Document constant NONE vs Python's None#255
robhudson merged 1 commit intomainfrom
229-doc-NONE-vs-None

Conversation

@robhudson
Copy link
Copy Markdown
Collaborator

No description provided.

@robhudson
Copy link
Copy Markdown
Collaborator Author

/cc @janbrasna

@janbrasna
Copy link
Copy Markdown
Contributor

Lovely. I actually after several attempts to improve the docs realized that the info was there all the time, just in a different place:

In the above example, the constant ``NONE`` is converted to the CSP keyword ``"'none'"`` and
is distinct from Python's ``None`` value. The CSP keyword ``'none'`` is a special value that
signifies that you do not want any sources for this directive. The ``None`` value is a
Python keyword that represents the absence of a value and when used as the value of a directive,
it will remove the directive from the policy.
This is useful when using the ``@csp_replace`` decorator to effectively clear a directive from
the base configuration as defined in the settings. For example, if the Django settings the
``frame-ancestors`` directive is set to a list of sources and you want to remove the
``frame-ancestors`` directive from the policy for this view:

But this addition is a great improvement nonetheless, for those not reading the doc linearly and just skimming through the examples/defaults etc., to help avoiding this quite an unfortunate confusion;)

Copy link
Copy Markdown
Contributor

@janbrasna janbrasna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(only adding a few naïve questions out of ignorance…)

Comment thread docs/configuration.rst Outdated
Comment thread docs/configuration.rst Outdated
@robhudson robhudson force-pushed the 229-doc-NONE-vs-None branch 2 times, most recently from 766894f to 806e07c Compare January 20, 2025 16:20
@robhudson robhudson force-pushed the 229-doc-NONE-vs-None branch from 806e07c to fb5f80a Compare January 20, 2025 17:20
@robhudson robhudson merged commit e6ae74e into main Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants