Skip to content

Commit

Permalink
Merge c03e2c2 into 3cebc69
Browse files Browse the repository at this point in the history
  • Loading branch information
Glenn Matthews committed Dec 4, 2019
2 parents 3cebc69 + c03e2c2 commit 914aaa4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
1 change: 0 additions & 1 deletion .travis.yml
@@ -1,7 +1,6 @@
sudo: false
language: python
python:
- "2.6"
- "2.7"
- "3.4"
- "3.5"
Expand Down
2 changes: 2 additions & 0 deletions requirements-checks.txt
@@ -1,4 +1,6 @@
# Python packages required to run `make check'.
flake8 >= 2.6.0
flake8-docstrings >= 0.2.8
# pydocstyle dropped support for Python 2.7 and pypy in 4.0
pydocstyle < 4.0.0
pyflakes >= 1.2.3
2 changes: 1 addition & 1 deletion tox.ini
@@ -1,5 +1,5 @@
[tox]
envlist = py26, py27, py34, py35, py36, pypy
envlist = py27, py34, py35, py36, pypy

[testenv]
deps = -rrequirements-tests.txt
Expand Down
23 changes: 18 additions & 5 deletions verboselogs/pylint.py
Expand Up @@ -10,7 +10,20 @@
.. _Pylint: https://pypi.python.org/pypi/pylint
"""

from astroid import MANAGER, scoped_nodes, nodes
from astroid import MANAGER

try:
# astroid 2.x
from astroid import FunctionDef as FunctionDef
from astroid import Const as Const
from astroid import ClassDef as ClassDef
from astroid import Module as Module
except ImportError:
# astroid 1.x
from astroid.scoped_nodes import Function as FunctionDef
from astroid.nodes import Const as Const
from astroid.scoped_nodes import Class as ClassDef
from astroid.scoped_nodes import Module as Module


def register(linter):
Expand All @@ -21,16 +34,16 @@ def verboselogs_class_transform(cls):
"""Make Pylint aware of our custom logger methods."""
if cls.name == 'RootLogger':
for meth in ['notice', 'spam', 'success', 'verbose']:
cls.locals[meth] = [scoped_nodes.Function(meth, None)]
cls.locals[meth] = [FunctionDef(meth, None)]


def verboselogs_module_transform(mod):
"""Make Pylint aware of our custom log levels."""
if mod.name == 'logging':
for const in ['NOTICE', 'SPAM', 'SUCCESS', 'VERBOSE']:
mod.locals[const] = [nodes.Const(const)]
mod.locals[const] = [Const(const)]


# Register the above methods with Pylint.
MANAGER.register_transform(scoped_nodes.Class, verboselogs_class_transform)
MANAGER.register_transform(scoped_nodes.Module, verboselogs_module_transform)
MANAGER.register_transform(ClassDef, verboselogs_class_transform)
MANAGER.register_transform(Module, verboselogs_module_transform)

0 comments on commit 914aaa4

Please sign in to comment.