#16216: Improve PEP8 compliance: replace "== None" by "is None"
-------------------------------------+-------------------------------------
Reporter: wluebbe | Owner:
Type: enhancement | Status: needs_review
Priority: minor | Milestone: sage-6.2
Component: build | Resolution:
Keywords: pep8 | Merged in:
Authors: Wilfried Luebbe | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
u/wluebbe/ticket/16216 | 1219d56b731119122356714ed4d26ae33c63cd5d
Dependencies: | Stopgaps:
-------------------------------------+-------------------------------------
Comment (by vdelecroix):
Hi,
Thanks Wilfried for providing your script. Your regexps look much nicer
than mine!
The syntax for regexp in sed is (almost) the same as in Python! You can
write what you did in sed as
{{{
sed -e's/\s\?==\s*None\b/ is None/g' \
-e's/\s\?!=\s*None\b/ is not None/g' my_file.py
}}}
Instead of the for loop, it is faster and cleaner to use xargs. The
following one-line command takes care of py and pyx files.
{{{
find -regex ".*pyx?" | xargs sed -i \
-e's/\s\?==\s*None\b/ is None/g' \
-e's/\s\?!=\s*None\b/ is not None/g'
}}}
With the command above I got 637 instances on 6.2.rc0.
At the very last, there are two possibilities to avoid occurrence of "bla
== None" in the future (see Volker's answer in
[[https://groups.google.com/forum/#!topic/sage-devel/SN93zx3YnAA|that
thread]]):
- provide a pre-commit hook for git
- modify the "sage -b" command
Vincent
PS: sed is not Unix but [[http://www.gnu.org/|GNU]]!
--
Ticket URL: <http://trac.sagemath.org/ticket/16216#comment:17>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.