Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove useless Pylint disables #1615

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions documentation/docbuild/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ def runSphinx(self):

if sphinx_new:
# noinspection PyPackageRequirements
import sphinx.cmd.build # pylint: disable=import-error
import sphinx.cmd.build
sphinx_main_command = sphinx.cmd.build.main
else:
sphinx_main_command = sphinx.main # pylint: disable=no-member

try: # pylint: disable=assignment-from-no-return
try:
returnCode = sphinx_main_command(sphinxOptions)
except SystemExit:
returnCode = 0
Expand Down
4 changes: 2 additions & 2 deletions documentation/nbvalNotebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import subprocess

# noinspection PyPackageRequirements
import pytest # pylint: disable=unused-import,import-error
import pytest # pylint: disable=unused-import
# noinspection PyPackageRequirements
import nbval # pylint: disable=unused-import,import-error
import nbval # pylint: disable=unused-import

from music21 import environment
from music21 import common
Expand Down
4 changes: 2 additions & 2 deletions documentation/testDocumentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
import time

# noinspection PyPackageRequirements
from docutils.core import publish_doctree # pylint: disable=import-error
from docutils.core import publish_doctree
# noinspection PyPackageRequirements
import docutils.nodes # pylint: disable=import-error
import docutils.nodes


import nbvalNotebook # TODO: make into a package and import with .nbvalNotebook
Expand Down
2 changes: 1 addition & 1 deletion music21/abcFormat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ def getQuarterLength(self,
ql = activeDefaultQuarterLength * int(numStr)

if self.brokenRhythmMarker is not None:
symbol, direction = self.brokenRhythmMarker # pylint: disable=unpacking-non-sequence
symbol, direction = self.brokenRhythmMarker
if symbol == '>':
modPair = (1.5, 0.5)
elif symbol == '<':
Expand Down
4 changes: 0 additions & 4 deletions music21/abcFormat/testFiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@

import unittest

# some lines must be this long, because of sources.
# pylint: disable=line-too-long


# abc standard
# http://abcnotation.com/abc2mtex/abc.txt
from music21 import environment
Expand Down
2 changes: 1 addition & 1 deletion music21/audioSearch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def autocorrelationFunction(recordedSignal, recordSampleRateIn):
correlation = correlation[lengthCorrelation:]
difference = numpy.diff(correlation) # Calculates the difference between slots
positiveDifferences = numpy.where(difference > 0)[0]
if len(positiveDifferences) == 0: # pylint: disable=len-as-condition
if len(positiveDifferences) == 0:
finalResult = 10 # Rest
else:
beginning = positiveDifferences[0]
Expand Down
8 changes: 4 additions & 4 deletions music21/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
from music21 import exceptions21
from music21 import prebase
from music21.sites import Sites, SitesException, WEAKREF_ACTIVE
from music21.style import Style # pylint: disable=unused-import
from music21.style import Style
from music21.sorting import SortTuple, ZeroSortTupleLow, ZeroSortTupleHigh
# needed for temporal manipulations; not music21 objects
from music21 import tie
Expand Down Expand Up @@ -165,7 +165,7 @@ def __new__(cls, tupEls):
# noinspection PyTypeChecker
return super(_SplitTuple, cls).__new__(cls, tuple(tupEls))

def __init__(self, tupEls): # pylint: disable=super-init-not-called
def __init__(self, tupEls):
self.spannerList = []

# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -673,7 +673,7 @@ def __getstate__(self) -> dict[str, t.Any]:

def __setstate__(self, state: dict[str, t.Any]):
# defining self.__dict__ upon initialization currently breaks everything
object.__setattr__(self, '__dict__', state) # pylint: disable=attribute-defined-outside-init
object.__setattr__(self, '__dict__', state)

def _reprInternal(self) -> str:
'''
Expand Down Expand Up @@ -3200,7 +3200,7 @@ def splitAtQuarterLength(
for listType in ('expressions', 'articulations'):
if hasattr(e, listType):
temp = getattr(e, listType)
setattr(e, listType, []) # pylint: disable=attribute-defined-outside-init
setattr(e, listType, [])
setattr(eRemain, listType, [])
for thisExpression in temp: # using thisExpression as a shortcut for expr or art.
if hasattr(thisExpression, 'splitClient'): # special method (see Trill)
Expand Down
2 changes: 1 addition & 1 deletion music21/chord/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def __deepcopy__(self: _ChordBaseType, memo=None) -> _ChordBaseType:
# after copying, if a Volume exists, it is linked to the old object
# look at _volume so as not to create object if not already there
# noinspection PyProtectedMember
for n in new._notes: # pylint: disable=no-member
for n in new._notes:
n._chordAttached = new
# if .volume is called, a new Volume obj will be created
if n.hasVolumeInformation():
Expand Down
1 change: 0 additions & 1 deletion music21/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

from music21 import defaults
from music21 import exceptions21
# pylint: disable=wildcard-import
from music21.common.classTools import * # including isNum, isListLike
from music21.common.decorators import * # gives the deprecated decorator
from music21.common.enums import *
Expand Down
2 changes: 0 additions & 2 deletions music21/common/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ def is_bool_tuple(v):
else:
return False

# pylint having Enum problems with classes as usual.
# pylint: disable=comparison-with-callable
def __eq__(self, other):
if isinstance(other, self.__class__):
return super().__eq__(other)
Expand Down
2 changes: 1 addition & 1 deletion music21/common/fileTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def readPickleGzip(filePath: str | pathlib.Path) -> t.Any:
try:
uncompressed = pickledFile.read()
newMdb = pickle.loads(uncompressed)
except Exception as e: # pylint: disable=broad-exception-caught
except Exception as e:
# pickle exceptions cannot be caught directly
# because they might come from pickle or _pickle and the latter cannot
# be caught.
Expand Down
2 changes: 0 additions & 2 deletions music21/common/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ def runParallel(iterable, parallelFunction, *,
>>> outputs
[99, 11, 123]
'''
# multiprocessing has trouble with introspection
# pylint: disable=not-callable
numCpus = cpus()

if numCpus == 1 or multiprocessing.current_process().daemon:
Expand Down
2 changes: 1 addition & 1 deletion music21/common/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from music21.common.enums import OffsetSpecial

if t.TYPE_CHECKING:
import music21 # pylint: disable=unused-import
import music21

DocOrder = list[str | Callable]
OffsetQL = float | Fraction
Expand Down
4 changes: 2 additions & 2 deletions music21/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,10 @@ def performAction(self, simulate=False):
else:
try:
self._performAction(simulate=simulate)
except DialogException: # pylint: disable=catching-non-exception
except DialogException:
# in some cases, the action selected requires exciting the
# configuration assistant
# pylint: disable=raising-non-exception,raise-missing-from
# pylint: disable=raise-missing-from
raise DialogException('perform action raised a dialog exception')


Expand Down
4 changes: 2 additions & 2 deletions music21/converter/subConverters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ def testImportMei3(self):
it was exported from
the "sibmei" plug-in for Sibelius).
'''
from unittest import mock # pylint: disable=no-name-in-module
from unittest import mock
with mock.patch('music21.mei.MeiToM21Converter') as mockConv:
testPath = common.getSourceFilePath() / 'mei' / 'test' / 'notes_in_utf16.mei'
testConverter = ConverterMEI()
Expand All @@ -1438,7 +1438,7 @@ def testImportMei4(self):
'''
For the sake of completeness, this is the same as testImportMei3() but with a UTF-8 file.
'''
from unittest import mock # pylint: disable=no-name-in-module
from unittest import mock
with mock.patch('music21.mei.MeiToM21Converter') as mockConv:
testPath = common.getSourceFilePath() / 'mei' / 'test' / 'notes_in_utf8.mei'
testConverter = ConverterMEI()
Expand Down
2 changes: 1 addition & 1 deletion music21/corpus/corpora.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ def __init__(self, name: str | None = None):
self._name = None
elif name in ('core', 'virtual'):
raise CorpusException(f'The name {name!r} is reserved.')
else: # pylint: disable=no-else-raise # false positive.
else:
self._name = name

# SPECIAL METHODS #
Expand Down
2 changes: 1 addition & 1 deletion music21/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def etIndent(elem, level=0, spaces=2):
indent an elementTree element for printing
'''
i = '\n' + level * spaces * ' '
if len(elem): # pylint: disable=len-as-condition
if len(elem):
if not elem.text or not elem.text.strip():
elem.text = i + spaces * ' '
if not elem.tail or not elem.tail.strip():
Expand Down
2 changes: 1 addition & 1 deletion music21/exceptions21.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class StreamException(Music21Exception):
pass

class ImmutableStreamException(StreamException):
def __init__(self, msg='An immutable Stream cannot be changed'): # pylint: disable=useless-super-delegation
def __init__(self, msg='An immutable Stream cannot be changed'):
super().__init__(msg)


Expand Down
4 changes: 1 addition & 3 deletions music21/features/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@

__all__ = ['base', 'outputFormats', 'jSymbolic', 'native']

# __init__ can wildcard import base; it's how it is designed.
from music21.features.base import * # pylint: disable=wildcard-import
from music21.features.base import *

from music21.features import base
from music21.features import outputFormats

from music21.features import jSymbolic
from music21.features import native

# pylint: disable=redefined-builtin
__doc__ = base.__doc__

2 changes: 1 addition & 1 deletion music21/graph/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ def processor(self):
if not self.processorClass:
return None
if not self._processor:
self._processor = self.processorClass(self.streamObj) # pylint: disable=not-callable
self._processor = self.processorClass(self.streamObj)
return self._processor

def run(self, *, callProcess: bool = True, **keywords):
Expand Down
2 changes: 0 additions & 2 deletions music21/humdrum/spineParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,6 @@ def parse(self):
elif eventC.startswith('!'):
thisObject = SpineComment(eventC)
else:
# pylint: disable=attribute-defined-outside-init
thisObject = base.ElementWrapper(event)
thisObject.humdrumPosition = event.position

Expand Down Expand Up @@ -1335,7 +1334,6 @@ def parse(self):
thisObject = self.processNoteEvent(eventC)

if thisObject is not None:
# pylint: disable=attribute-defined-outside-init
thisObject.humdrumPosition = event.position
thisObject.priority = event.position
self.stream.coreAppend(thisObject)
Expand Down
4 changes: 2 additions & 2 deletions music21/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -3676,7 +3676,7 @@ def noteStart(self) -> music21.note.Note | None:
if p and p._client:
return p._client
elif p:
from music21 import note # pylint: disable=redefined-outer-name
from music21 import note
return note.Note(pitch=p)

@noteStart.setter
Expand All @@ -3696,7 +3696,7 @@ def noteEnd(self) -> music21.note.Note | None:
if p and p._client:
return p._client
elif p:
from music21 import note # pylint: disable=redefined-outer-name
from music21 import note
return note.Note(pitch=p)

@noteEnd.setter
Expand Down
3 changes: 0 additions & 3 deletions music21/lily/lilyObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
# Copyright: Copyright © 2007-2012 Michael Scott Asato Cuthbert
# License: BSD, see license.txt
# ------------------------------------------------------------------------------
# pylint: disable=too-many-function-args
# unfortunately the way this was originally set up the previous line is needed
'''
music21 translates to Lilypond format and if Lilypond is installed on the
local computer, can automatically generate .pdf, .png, and .svg versions
Expand Down Expand Up @@ -2265,7 +2263,6 @@ def testOneNoteTheHardWay(self):


if __name__ == '__main__':
# pylint: disable=ungrouped-imports
import music21
music21.mainTest(Test)

1 change: 0 additions & 1 deletion music21/lily/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2667,7 +2667,6 @@ def testStaffLines(self):

# ------------------------------------------------------------------------------
if __name__ == '__main__':
# pylint: disable=ungrouped-imports
import music21
music21.mainTest(Test) # , TestExternal)
# music21.mainTest(TestExternal, 'noDocTest')
Expand Down
8 changes: 4 additions & 4 deletions music21/mei/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def __init__(self, theDocument=None):
if isinstance(self.documentRoot, ElementTree):
# pylint warns that :class:`Element` doesn't have a getroot() method, which is
# true enough, but...
self.documentRoot = self.documentRoot.getroot() # pylint: disable=maybe-no-member
self.documentRoot = self.documentRoot.getroot()

if f'{MEI_NS}mei' != self.documentRoot.tag:
raise MeiElementError(_WRONG_ROOT_ELEMENT.format(self.documentRoot.tag))
Expand Down Expand Up @@ -419,7 +419,7 @@ def makeDuration(
0.5
'''
returnDuration = duration.Duration(base)
returnDuration.dots = dots # pylint: disable=assigning-non-slot
returnDuration.dots = dots
return returnDuration


Expand Down Expand Up @@ -1521,7 +1521,7 @@ def _guessTuplets(theLayer):

# Element-Based Converter Functions
# -----------------------------------------------------------------------------
def scoreDefFromElement(elem, slurBundle=None): # pylint: disable=unused-argument
def scoreDefFromElement(elem, slurBundle=None):
'''
<scoreDef> Container for score meta-information.

Expand Down Expand Up @@ -1694,7 +1694,7 @@ def staffGrpFromElement(elem, slurBundle=None, staffDefDict=None):
return staffDefDict


def staffDefFromElement(elem, slurBundle=None): # pylint: disable=unused-argument
def staffDefFromElement(elem, slurBundle=None):
'''
<staffDef> Container for staff meta-information.

Expand Down
7 changes: 1 addition & 6 deletions music21/mei/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
# if we mock many things, this may be triggered
# pylint: disable=too-many-arguments

# pylint is bad at guessing types in these tests---reasonably so
# pylint: disable=maybe-no-member

# pylint: disable=ungrouped-imports
# pylint: disable=import-error
import unittest

# To have working MagicMock objects, we can't use cElementTree even though it would be faster.
Expand All @@ -36,7 +31,7 @@

from collections import defaultdict
from fractions import Fraction
from unittest import mock # pylint: disable=no-name-in-module
from unittest import mock

from music21 import articulations
from music21 import bar
Expand Down
1 change: 0 additions & 1 deletion music21/metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2420,7 +2420,6 @@ def _convertValue(uniqueName: str, value: t.Any) -> ValueType:

if valueType is int:
# noinspection PyBroadException
# pylint: disable=bare-except
try:
return int(value)
except:
Expand Down
2 changes: 1 addition & 1 deletion music21/metadata/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def process_serial(jobs):
# -----------------------------------------------------------------------------


class WorkerProcess(multiprocessing.Process): # pylint: disable=inherit-non-class
class WorkerProcess(multiprocessing.Process):
'''
A worker process for use by the multithreaded metadata-caching job
processor.
Expand Down
1 change: 0 additions & 1 deletion music21/metadata/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ def datetime(self):
Traceback (most recent call last):
TypeError: ...argument 'day' (pos 3)...
'''
# pylint: disable=no-value-for-parameter
post = []
# order here is order for datetime
# TODO: need defaults for incomplete times.
Expand Down
3 changes: 1 addition & 2 deletions music21/midi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,7 @@ def __repr__(self):

@classmethod
def hasValue(cls, val):
# https://github.com/PyCQA/pylint/issues/3941
return val in cls._value2member_map_ # pylint: disable=no-member
return val in cls._value2member_map_


class ChannelVoiceMessages(_ContainsEnum):
Expand Down
1 change: 0 additions & 1 deletion music21/musicxml/m21ToXml.py
Original file line number Diff line number Diff line change
Expand Up @@ -6959,7 +6959,6 @@ def setMxAttributesObjectForStartOfMeasure(self):
if mxMeasureStyle is not None:
mxAttributes.append(mxMeasureStyle)

# pylint: disable=len-as-condition
if len(mxAttributes) > 0 or mxAttributes.attrib:
self.xmlRoot.append(mxAttributes)
return mxAttributes
Expand Down
Loading