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

Sourcery refactored master branch #34

Merged
merged 2 commits into from
Jun 16, 2020
Merged

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jun 16, 2020

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment on lines -361 to +366
tokens = []
for attr in ["note", "vel", "ctl", "val"]:
if hasattr(self, attr):
tokens.append("%s%i" % (attr[0], getattr(self, attr)))
tokens = [
"%s%i" % (attr[0], getattr(self, attr))
for attr in ["note", "vel", "ctl", "val"]
if hasattr(self, attr)
]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Note.__str__ refactored with the following changes:

  • Convert for loop into list comprehension

Comment on lines -452 to +455
if self.vel == 0:
vv = " "
else:
vv = "{:02X}".format(self.vel - 1)
if self.module == 0:
mmmm = " "
else:
mmmm = "{:04X}".format(self.module - 1)
vv = " " if self.vel == 0 else "{:02X}".format(self.vel - 1)
mmmm = " " if self.module == 0 else "{:04X}".format(self.module - 1)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Note.tabular_repr refactored with the following changes:

  • Split conditional into multiple branches
  • Merge duplicate blocks in conditional
  • Remove redundant conditional
  • Replace if statement with if expression

for track_no in range(self.tracks):
for _ in range(self.tracks):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Pattern.clear refactored with the following changes:

  • Replace unused for index with underscore

Comment on lines -141 to +145
for chunk in pattern.iff_chunks():
yield chunk
yield from pattern.iff_chunks()
yield (b"PEND", b"")
for i, module in enumerate(self.modules):
if module is not None:
for chunk in module.iff_chunks():
yield chunk
yield from module.iff_chunks()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Project.chunks refactored with the following changes:

  • Simplify sequence comparison
  • Replace yield inside for loop with yield from

Comment on lines -238 to +239
pattern_lines = []
for index, pattern in active_patterns:
pattern_lines.append(
PatternLine(index, pattern.source or index, line - pattern.x)
)
pattern_lines = [
PatternLine(index, pattern.source or index, line - pattern.x)
for index, pattern in active_patterns
]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Project.pattern_lines refactored with the following changes:

  • Convert for loop into list comprehension

Comment on lines -228 to +223
if chunk.chnm == 1:
elif chunk.chnm == 1:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function MultiCtl.load_chunk refactored with the following changes:

  • Simplify conditional into switch-like form

Comment on lines -263 to +258
if gains and len(gains) == 1:
gain = list(gains).pop()
else:
gain = 256
gain = list(gains).pop() if gains and len(gains) == 1 else 256
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function MultiCtl.macro refactored with the following changes:

  • Replace if statement with if expression

Comment on lines -63 to +65
for chunk in self.nv_curve.chunks():
yield chunk
for chunk in super(MultiSynth, self).specialized_iff_chunks():
yield chunk
for chunk in self.vv_curve.chunks():
yield chunk
yield from self.nv_curve.chunks()
yield from super(MultiSynth, self).specialized_iff_chunks()
yield from self.vv_curve.chunks()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function MultiSynth.specialized_iff_chunks refactored with the following changes:

  • Replace yield inside for loop with yield from

Comment on lines -325 to +329
for chunk in iter:
yield chunk
for chunk in super(Sampler, self).specialized_iff_chunks():
yield chunk
yield from iter
yield from super(Sampler, self).specialized_iff_chunks()
for i, sample in enumerate(self.samples):
if sample is not None:
for chunk in self.sample_chunks(i, sample):
yield chunk
yield from self.sample_chunks(i, sample)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Sampler.specialized_iff_chunks refactored with the following changes:

  • Replace yield inside for loop with yield from

Comment on lines -119 to +123
for chunk in self.harmonic_freqs.chunks():
yield chunk
for chunk in self.harmonic_volumes.chunks():
yield chunk
for chunk in self.harmonic_widths.chunks():
yield chunk
for chunk in self.harmonic_types.chunks():
yield chunk
for chunk in super(SpectraVoice, self).specialized_iff_chunks():
yield chunk
yield from self.harmonic_freqs.chunks()
yield from self.harmonic_volumes.chunks()
yield from self.harmonic_widths.chunks()
yield from self.harmonic_types.chunks()
yield from super(SpectraVoice, self).specialized_iff_chunks()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SpectraVoice.specialized_iff_chunks refactored with the following changes:

  • Replace yield inside for loop with yield from

for chunk in super(VorbisPlayer, self).specialized_iff_chunks():
yield chunk
yield from super(VorbisPlayer, self).specialized_iff_chunks()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function VorbisPlayer.specialized_iff_chunks refactored with the following changes:

  • Replace yield inside for loop with yield from

Comment on lines -49 to +50
for chunk in self.curve.chunks():
yield chunk
for chunk in super(WaveShaper, self).specialized_iff_chunks():
yield chunk
yield from self.curve.chunks()
yield from super(WaveShaper, self).specialized_iff_chunks()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function WaveShaper.specialized_iff_chunks refactored with the following changes:

  • Replace yield inside for loop with yield from

if self._index > 0:
self.object = Module(index=self._index)
else:
self.object = Output()
self.object = Module(index=self._index) if self._index > 0 else Output()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ModuleReader.process_chunks refactored with the following changes:

  • Replace if statement with if expression

Comment on lines -43 to +45
self._controller_keys = list(
self._controller_keys = [
name
for name, controller in new_module.controllers.items()
if controller.attached(new_module)
)
]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ModuleReader.process_STYP refactored with the following changes:

  • Replace list(), dict() or set() with comprehension

Comment on lines -97 to +98
links = self.object.incoming_links
if len(data) > 0:
link_count = len(data) // 4
structure = "<" + "i" * link_count
links = self.object.incoming_links
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ModuleReader.process_SLNK refactored with the following changes:

  • Move assignments closer to their usage

return (
return ((
(p[0] == q[0] and abs(p[1] - q[1]) == 1)
or (p[1] == q[1] and abs(p[0] - q[0]) == 1)
) and not ((abs(p[0] - q[0]) == 1) and abs(p[1] - q[1]) == 1)
)) and (abs(p[0] - q[0]) != 1 or abs(p[1] - q[1]) != 1)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function module_layout.is_neighbour refactored with the following changes:

  • Simplify logical expression

Comment on lines -260 to +259
for i in range(n - 1):
for _ in range(n - 1):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function module_layout.sample refactored with the following changes:

  • Replace unused for index with underscore

Comment on lines -282 to +281
return sum([(s[i] - head[i]) ** 2 for i in range(2)])
return sum((s[i] - head[i]) ** 2 for i in range(2))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function module_layout.compactness.err refactored with the following changes:

  • Replace unneeded comprehension with generator

Comment on lines -288 to +287
for i in range(tries):
for _ in range(tries):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function module_layout.best refactored with the following changes:

  • Replace unused for index with underscore

Comment on lines -352 to +351
npatches = len(list(set([patch["name"] for patch in patches])))
npatches = len(list({patch["name"] for patch in patches}))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

  • Replace unneeded comprehension with generator
  • Replace list(), dict() or set() with comprehension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants