8th day of python challenges 111-117

This commit is contained in:
abd.shallal
2019-08-04 15:26:35 +03:00
parent b04c1b055f
commit 627802c383
3215 changed files with 760227 additions and 491 deletions

View File

@@ -0,0 +1,4 @@
[MASTER]
optimize-ast=no

View File

@@ -0,0 +1,4 @@
"""a package with absolute import activated
"""
from __future__ import absolute_import

View File

@@ -0,0 +1,7 @@
"""
http://www.logilab.org/ticket/70495
http://www.logilab.org/ticket/70565
"""
from __future__ import absolute_import, print_function
import string
print(string)

View File

@@ -0,0 +1 @@
ABC = something_undefined

View File

@@ -0,0 +1,2 @@
import missing
raise missing.Missing..

View File

@@ -0,0 +1,5 @@
"""
Test that pylint doesn't crash when a relative import
depends on the local __init__, which contains an expected syntax error.
"""
from . import missing

View File

@@ -0,0 +1,6 @@
from ... import Something
from . import data
try:
from ... import Lala
except ImportError:
pass

View File

@@ -0,0 +1 @@
Anything = 42

View File

@@ -0,0 +1,17 @@
"""ds"""
__revision__ = None
# pylint: disable=useless-object-inheritance
class SomeClass(object):
"""cds"""
doc = __doc__
def __init__(self):
"""only to make pylint happier"""
def please(self):
"""public method 1/2"""
def besilent(self):
"""public method 2/2"""

View File

@@ -0,0 +1,7 @@
[MESSAGES CONTROL]
disable=all
enable=
trailing-whitespace, # Caring about it
bad-indentation, # And about this
# And about this
missing-docstring

View File

@@ -0,0 +1,10 @@
"""hum E1011 on .prec member is justifiable since Context instance are built
using setattr/locals :(
2007/02/17 update: .prec attribute is now detected by astroid :o)
"""
from __future__ import print_function
import decimal
decimal.getcontext().prec = 200
print(decimal.getcontext().prec)

View File

@@ -0,0 +1,20 @@
# -*- coding: iso-8859-1 -*-
import urllib
class Page(object):
_urlOpen = staticmethod(urllib.urlopen)
def getPage(self, url):
handle = self._urlOpen(url)
data = handle.read()
handle.close()
return data
#_getPage
#Page
if __name__ == "__main__":
import sys
p = Page()
print p.getPage(sys.argv[1])

View File

@@ -0,0 +1,3 @@
# pylint: disable=missing-docstring
from .dummy import DUMMY
from .another import ANOTHER

View File

@@ -0,0 +1,3 @@
# pylint: disable=missing-docstring
ANOTHER = 42

View File

@@ -0,0 +1,2 @@
# pylint: disable=missing-docstring
DUMMY = 42

View File

@@ -0,0 +1,6 @@
[MASTER]
load-plugins=dummy_plugin
[DUMMY_PLUGIN]
dummy_option_1="dummy value 1"
dummy_option_2="dummy value 2"

View File

@@ -0,0 +1,6 @@
def register(linter):
pass
def load_configuration(linter):
linter.config.black_list += ('bin',)

View File

@@ -0,0 +1,30 @@
from pylint.checkers import BaseChecker
class DummyPlugin1(BaseChecker):
name = 'dummy_plugin'
msgs = {'I9061': ('Dummy short desc 01', 'dummy-message-01', 'Dummy long desc')}
options = (
('dummy_option_1', {
'type': 'string',
'metavar': '<string>',
'help': 'Dummy option 1',
}),
)
class DummyPlugin2(BaseChecker):
name = 'dummy_plugin'
msgs = {'I9060': ('Dummy short desc 02', 'dummy-message-02', 'Dummy long desc')}
options = (
('dummy_option_2', {
'type': 'string',
'metavar': '<string>',
'help': 'Dummy option 2',
}),
)
def register(linter):
linter.register_checker(DummyPlugin1(linter))
linter.register_checker(DummyPlugin2(linter))

View File

@@ -0,0 +1,5 @@
import shmixml.dom.minidom
import xml.dom.minidom
if 'dom' not in xml.__dict__:
xml.dom = shmixml.dom

View File

@@ -0,0 +1,49 @@
# pylint: disable=I0011,C0301,W0611
"""I found some of my scripts trigger off an AttributeError in pylint
0.8.1 (with common 0.12.0 and astroid 0.13.1).
Traceback (most recent call last):
File "/usr/bin/pylint", line 4, in ?
lint.Run(sys.argv[1:])
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 729, in __init__
linter.check(args)
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 412, in check
self.check_file(filepath, modname, checkers)
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 426, in check_file
astroid = self._check_file(filepath, modname, checkers)
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 450, in _check_file
self.check_astroid_module(astroid, checkers)
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 494, in check_astroid_module
self.astroid_events(astroid, [checker for checker in checkers
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 511, in astroid_events
self.astroid_events(child, checkers, _reversed_checkers)
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 511, in astroid_events
self.astroid_events(child, checkers, _reversed_checkers)
File "/usr/lib/python2.4/site-packages/pylint/lint.py", line 508, in astroid_events
checker.visit(astroid)
File "/usr/lib/python2.4/site-packages/logilab/astroid/utils.py", line 84, in visit
method(node)
File "/usr/lib/python2.4/site-packages/pylint/checkers/variables.py", line 295, in visit_import
self._check_module_attrs(node, module, name_parts[1:])
File "/usr/lib/python2.4/site-packages/pylint/checkers/variables.py", line 357, in _check_module_attrs
self.add_message('E0611', args=(name, module.name),
AttributeError: Import instance has no attribute 'name'
You can reproduce it by:
(1) create package structure like the following:
package/
__init__.py
subpackage/
__init__.py
module.py
(2) in package/__init__.py write:
import subpackage
(3) run pylint with a script importing package.subpackage.module.
"""
import package.subpackage.module
__revision__ = '$Id: import_package_subpackage_module.py,v 1.1 2005-11-10 16:08:54 syt Exp $'

View File

@@ -0,0 +1,4 @@
# pylint: disable=missing-docstring,unused-import
import os
import sys

View File

@@ -0,0 +1 @@
from empty import *

View File

@@ -0,0 +1,3 @@
# pylint: disable=invalid-name, missing-docstring
# pylint: disable=unbalanced-tuple-unpacking
n = 42

View File

@@ -0,0 +1,7 @@
# pylint: disable=W0603,W0601,W0604,E0602,W0104
"""was causing infinite recursion
"""
__revision__ = 1
global GLOBAL_VAR
GLOBAL_VAR.foo

View File

@@ -0,0 +1,4 @@
#-*- coding:iso-8859-1 -*-
class test:
def __init__(self, dir):
testString = u"répertoire :\n%s !"%dir

View File

@@ -0,0 +1,7 @@
"""#10077"""
__revision__ = 1
from numarray import zeros
zeros(shape=(4, 5))

View File

@@ -0,0 +1,5 @@
"""#3216"""
import numarray as na
import numarray.random_array as nar
IM16 = nar.randint(0, 256, 300).astype(na.UInt8)

View File

@@ -0,0 +1,3 @@
"""test preceded by the AudioTime class in __init__.py"""
__revision__ = 0

View File

@@ -0,0 +1,15 @@
# pylint: disable=R0903,W0403
"""package's __init__ file"""
from . import subpackage
__revision__ = 0
# E0602 - Undefined variable '__path__'
__path__ += "folder"
class AudioTime:
"""test precedence over the AudioTime submodule"""
DECIMAL = 3

View File

@@ -0,0 +1 @@
"""package.subpackage"""

View File

@@ -0,0 +1 @@
"""package.subpackage.module"""

View File

@@ -0,0 +1,3 @@
""" Check for E0603 for missing submodule found in __all__ """
__revision__ = 1
__all__ = ['notmissing', 'missing']

View File

@@ -0,0 +1,2 @@
""" empty """
__revision__ = 1

View File

@@ -0,0 +1,21 @@
"""
# package/__init__.py
class AudioTime(object):
DECIMAL = 3
# package/AudioTime.py
class AudioTime(object):
pass
# test.py
from package import AudioTime
# E0611 - No name 'DECIMAL' in module 'AudioTime.AudioTime'
print AudioTime.DECIMAL
"""
from __future__ import print_function
from package import AudioTime
__revision__ = 0
print(AudioTime.DECIMAL)

View File

@@ -0,0 +1,2 @@
[MESSAGES CONTROL]
disable=no-absolute-import

View File

@@ -0,0 +1,11 @@
"""Contains both normal error messages and Python3 porting error messages."""
# pylint: disable=too-few-public-methods
raise Exception, 1 # Error emitted here with the Python 3 checker.
class Test(object):
"""dummy"""
def __init__(self):
return 42

View File

@@ -0,0 +1,19 @@
"""Contains both normal error messages and Python3 porting error messages."""
# pylint: disable=too-few-public-methods
# error: import missing `from __future__ import absolute_import`
import sys
# error: Use raise ErrorClass(args) instead of raise ErrorClass, args.
raise Exception, 1
class Test(object):
"""dummy"""
def __init__(self):
# warning: Calling a dict.iter*() method
{1: 2}.iteritems()
return 42
# error: print statement used
print 'not in python3'

View File

@@ -0,0 +1,3 @@
class Klass(object):
"""A"""
__doc__ += "B"

View File

@@ -0,0 +1 @@
class A extends B {}

View File

@@ -0,0 +1,2 @@
def f(x):
return x # 1 space

View File

@@ -0,0 +1,5 @@
try:
pass
finally:
# pylint: disable=W0201
pass

View File

@@ -0,0 +1,6 @@
# pylint: disable=missing-docstring
def test():
variable = ''
variable2 = None
return variable2

View File

@@ -0,0 +1 @@
from empty import *

View File

@@ -0,0 +1,11 @@
"""Test that wrong-import-position is properly reset when
other errors are disabled.
"""
# pylint: disable=unused-import, too-few-public-methods
class Something(object):
"""A class before an import."""
import os