Skip to content

Sourcery Starbot ⭐ refactored leika/USB_Deck#1

Open
SourceryAI wants to merge 1 commit intoleika:masterfrom
SourceryAI:master
Open

Sourcery Starbot ⭐ refactored leika/USB_Deck#1
SourceryAI wants to merge 1 commit intoleika:masterfrom
SourceryAI:master

Conversation

@SourceryAI
Copy link
Copy Markdown

Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨

Here's your pull request refactoring your most popular Python repo.

If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.

Review changes via command line

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

git fetch https://github.com/sourcery-ai-bot/USB_Deck master
git merge --ff-only FETCH_HEAD
git reset HEAD^

try:
if package:
p = __import__(package + ".R", None, None, True)
p = __import__(f"{package}.R", None, None, True)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function resource_stream refactored with the following changes:

if l is not None:
return l
return "LVL%s" % level
return l if l is not None else f"LVL{level}"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Logger._level_str refactored with the following changes:

Comment on lines -41 to +39
_stream.write("%s:%s:" % (self._level_str(level), self.name))
_stream.write(f"{self._level_str(level)}:{self.name}:")
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Logger.log refactored with the following changes:

Comment on lines -31 to -34
l = f.readinto(buf)
if not l:
if l := f.readinto(buf):
yield from writer.awrite(buf, 0, l)
else:
break
yield from writer.awrite(buf, 0, l)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function sendstream refactored with the following changes:

return
yield from writer.awrite("\r\n")
if isinstance(headers, bytes) or isinstance(headers, str):
if isinstance(headers, (bytes, str)):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function start_response refactored with the following changes:

def render_expr(self, e):
self.indent()
self.file_out.write('yield str(' + e + ')\n')
self.file_out.write(f'yield str({e}' + ')\n')
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Compiler.render_expr refactored with the following changes:

self.args = tokens[1]
else:
self.args = ""
self.args = tokens[1] if len(tokens) > 1 else ""
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Compiler.parse_statement refactored with the following changes:

Comment on lines -161 to +155
if isinstance(p.__path__, str):
# uPy
self.pkg_path = p.__path__
else:
# CPy
self.pkg_path = p.__path__[0]
self.pkg_path = p.__path__ if isinstance(p.__path__, str) else p.__path__[0]
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Loader.__init__ refactored with the following changes:

This removes the following comments ( why? ):

# CPy
# uPy

Comment on lines -174 to +163
return self.dir + "/" + template.replace(".", "_") + ".py"
return f"{self.dir}/" + template.replace(".", "_") + ".py"
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Loader.compiled_path refactored with the following changes:

Comment on lines -185 to +177
f_out = open(compiled_path, "w")
c = Compiler(f_in, f_out, loader=self)
c.compile()
f_in.close()
f_out.close()
with open(compiled_path, "w") as f_out:
c = Compiler(f_in, f_out, loader=self)
c.compile()
f_in.close()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Function Loader.load refactored with the following changes:

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.

1 participant