Skip to content

Commit

Permalink
Ruff on master branch (#493)
Browse files Browse the repository at this point in the history
* Ruff on master branch

* ruff --select=E711,E712,E713 --fix .
  • Loading branch information
cclauss authored May 4, 2023
1 parent fbdb9cf commit 3722cd6
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 15 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/check-code-and-run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ on:
branches: [ master ]

jobs:
ruff:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- run: pip install --user ruff
- run: ruff --ignore=E401,E402,E701,E722,E731,E741,F401,F403,F405,F523,F524,F811,F841
--format=github --line-length=2793 --show-source --target-version=py37 .
build:
runs-on: macos-latest
strategy:
Expand Down
8 changes: 4 additions & 4 deletions bin/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def call(*args, **kwargs):

if AUTODOWNLOAD_DEPENDENCIES:
libpath = os.path.join(os.environ['STASH_ROOT'], 'lib')
if not libpath in sys.path:
if libpath not in sys.path:
sys.path.insert(1, libpath)
download_dulwich = False

Expand Down Expand Up @@ -381,10 +381,10 @@ def git_reset(args):
commit = ns.commit
# first arg was really a file
paths = ns.paths or []
if not commit in repo and os.path.exists(commit): #really specified a path
if commit not in repo and os.path.exists(commit): #really specified a path
paths = [commit] + paths
commit = None
elif not commit in repo and not commit in repo.branches and not commit in repo.remote_branches and not os.path.exists(
elif commit not in repo and commit not in repo.branches and commit not in repo.remote_branches and not os.path.exists(
commit):
raise Exception('{} is not a valid commit or file'.format(commit))
if not commit:
Expand Down Expand Up @@ -429,7 +429,7 @@ def get_config_or_prompt(repo, section, name, prompt, save=None):
value = config.get(section, name)
except KeyError:
value = input(prompt).encode()
if save == None:
if save is None:
reply = input('Save this setting? [y/n]')
save = reply == 'y'
if save:
Expand Down
2 changes: 1 addition & 1 deletion bin/httpserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def deal_post_data(self):
remainbytes = int(self.headers['content-length'])
line = self.rfile.readline()
remainbytes -= len(line)
if not boundary in line:
if boundary not in line:
return (False, "Content NOT begin with boundary")
line = self.rfile.readline()
remainbytes -= len(line)
Expand Down
2 changes: 1 addition & 1 deletion bin/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def send(self, sendto='', subject='', attach='', body=' '):
)
args = ap.parse_args()
smail = Mail(CONFIG, args.verbose)
if args.e == True:
if args.e is True:
smail.edit_cfg()
elif args.message or args.file and args.sendto:
if args.message == '-':
Expand Down
2 changes: 1 addition & 1 deletion bin/mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def list_mounts():
else:
manager.enable_patches()

if not ns.type in FILESYSTEM_TYPES:
if ns.type not in FILESYSTEM_TYPES:
print(_stash.text_color("Error: Unknown Filesystem-Type!", "red"))
sys.exit(1)

Expand Down
2 changes: 1 addition & 1 deletion bin/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def verbose_ping(dest_addr, timeout=2, count=4, interval=1.0):
print("failed. (socket error: '%s')" % e[1])
break

if delay == None:
if delay is None:
print("failed. (timeout within %ssec.)" % timeout)
else:
time.sleep(min(0, interval - delay))
Expand Down
4 changes: 2 additions & 2 deletions bin/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def update_req_index(pip_info_file=PIP_INFO_FILE, site_packages=SITE_PACKAGES_FO
requires = []
try:
for req in info['requires_dist']:
if not ';' in req:
if ';' not in req:
#Remove package version
requires.append(req.split(' ')[0])
except TypeError:# some package may have no require
Expand Down Expand Up @@ -782,7 +782,7 @@ def _run_setup_file(self, filename, extras=[]):
if self.verbose:
print("Handling commandline script: {s}".format(s=script))
cmdname = script.replace(os.path.dirname(script), "").replace("/", "")
if not "." in cmdname:
if '.' not in cmdname:
cmdname += ".py"
scriptpath = os.path.join(source_folder, script)
with open(scriptpath, "r") as fin:
Expand Down
4 changes: 2 additions & 2 deletions lib/git/git-branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def format_tracking_branch_desc(repo, branchname):
def edit_branch_description(branchname, description=None):
description = description or input('enter description:')
config = _get_repo().repo.get_config()
if not branchname in _get_repo().branches:
if branchname not in _get_repo().branches:
GitError('{} is not an existing branch'.format(branchname))
config.set(('branch', branchname), 'description', description)
config.write_to_path()
Expand Down Expand Up @@ -284,7 +284,7 @@ def create_branch(new_branch, base_rev, force=False, no_track=False):
#handle tracking, only if this was a remote
tracking, remote_branch = (['origin'] + base_rev.split('/'))[-2:] #branch-> origin/branch. remote/branch stays as is
qualified_remote_branch = os.path.sep.join([tracking, remote_branch])
if qualified_remote_branch in repo.remote_branches and not base_rev in repo.branches:
if qualified_remote_branch in repo.remote_branches and base_rev not in repo.branches:
if not no_track:
add_tracking(new_branch, tracking, remote_branch)
else:
Expand Down
3 changes: 2 additions & 1 deletion lib/libdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ def clipboard_set(s):
pyperclip.copy(s)
else:
# use fake implementation
global _CLIPBOARD; _CLIPBOARD = u""
global _CLIPBOARD
_CLIPBOARD = u""

def clipboard_get():
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/stashutils/mount_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def mount_fsi(self, path, fsi, readonly=False):
def unmount_fsi(self, path, force=False):
"""unmounts a fsi."""
path = os.path.abspath(path)
if not path in self.path2fs:
if path not in self.path2fs:
raise MountError("Nothing mounted there.")
fsi, readonly = self.path2fs[path]
if not force:
Expand Down
2 changes: 1 addition & 1 deletion tools/pythonista_reinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def remove_stash():


def install_stash(repo="ywangd", branch="master"):
if not "TMPDIR" in os.environ:
if "TMPDIR" not in os.environ:
os.environ["TMPDIR"] = tempfile.gettempdir()
ns = {"_owner": repo, "_br": branch}
exec(requests.get("https://bit.ly/get-stash").content, ns, ns)
Expand Down

0 comments on commit 3722cd6

Please sign in to comment.