Great ! Thanks for sharing.
JM
Torsten Marek wrote:
Hi all,
I'm sending a couple of patches that we wrote internally for our
custom extended pylint version. Some of the patches expose more
configuration options, other ones fix exotic crashes. I'll explain all
of them separately.
The patches were written for 0.23, but I've tested all of them against
0.24, and updated them so they apply cleanly.
* classmethod_first_arg_name
Exposes the valid name of the first argument to a classmethod as a
configuration option.
* import_assign_crash
Fixes an issue with conditionally assigning a nonexisting module to
intermediate modules in a dotted name.
This is only a cosmetic fix to avoid the crash, the actual fix
probably needs a lot of work on the inference module to support
conditional assignment and inspection of several places of assignment,
rather than just the latest one. Probably not worth it, either.
* infer__bases__
Fixes a bug with incorrectly inferring the base classes This led to a
crash in code like
class X(some bases...)
def __init__(self, ...):
for b in self.__class__.__bases__:
# do sth with b
* newstyle_type_fix
Fixes misleading wording in warnings E1001 and E1002.
* nocatch_exception_types
Exposes the list of exceptions that should not be caught as a
configuration option.
* no_main_import
Fixes a problem when a module imports __main__. While this is benign
normally (pylint just imports itself, and exposes its __main__ module
to astng, which is wrong, but not fatal), this led to a crash in our
deployed, standalone pylint version.
The fix is now that a completely empty module is returned, since
neither the linter nor the module in question can make any assumptions
about __main__.
* no_special_attr_scop_lookup_crash
Fixes a crash that occurs when lookup up a special attribute in class
scope (i.e. during class construction). This is not a total fix, which
would introduce a mechanism similar to special attribute lookup in
modules. Also, in order to get correct inference in this case, the
scope lookup rules would need to be changed to return the initial
assignment (which does not exist in code per se) as well as any later
modifications.
* str_getitem_infer_fix
This one is cute. It's a fix for a crash that occurs on code like
"any string literal"[0].upper()
due to the fact that the extracted string literal is not properly
wrapped, but returned as a naked string object.
The fixes for the crashes were all found while running gpylint over a
significant subset of the Python code at Google, the new configuration
options are needed to make gpylint adhere to our internal style guide,
but might be useful to others as well.
// Torsten
--
Site Reliability Engineer ∘ Google ✚ ∘ ⬕
------------------------------------------------------------------------
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects