Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Check for D302 if at Python 3.3+ and using explicit unicode prefix. #178

Closed
wants to merge 1 commit into from

Conversation

toroettg
Copy link
Contributor

@toroettg toroettg commented Mar 5, 2016

Since Python 3.3, Unicode string literal prefixes have been reintroduced, but D302 is exclusively reported for Python 2.

This proposes an implementation to report D302 if and only if a Unicode prefix has been explicitly added to the docstring for Python 3. The behavior of D302 for Python 2 is not changed.

This also adds some test cases to the already existing Unicode integration test (pypy3 currently implements Python 3.2, only). To avoid code duplication, this has been implemented as a single test case with multiple checks. Let me know if you would like to see those in separate tests.

if not is_ascii(docstring) and not docstring.startswith(
('u', 'ur')):
if docstring and not docstring.startswith('u'):
if sys.version_info < (3, 0) and not is_ascii(docstring):
Copy link
Member

Choose a reason for hiding this comment

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

Use six.PY3 / six.PY2 instead.

Copy link
Contributor Author

@toroettg toroettg Jun 5, 2016

Choose a reason for hiding this comment

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

Since this would add the first runtime dependency to the project, and thus break its advertised self-containedness, I suggest you integrate the library as you best see fit. I will then rebase / adjust the PR accordingly. However, I think the benefit at this particular location would by marginally, as six does not offer minor version (range) distinction.

@samj1912
Copy link
Member

samj1912 commented Mar 2, 2020

This PR has not had any updates in 3 years. Closing this for now. If there's any interest in resuming this, feel free to reopen.

@samj1912 samj1912 closed this Mar 2, 2020
@samj1912 samj1912 added the stale label Mar 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants