Skip to content

Commit

Permalink
removed ruff warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
arohanajit committed Sep 8, 2024
1 parent 98e3fe1 commit 285b576
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions python/libgrass_interface_generator/ctypesgen/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from subprocess import Popen, PIPE
import os
from os import path
from pathlib import Path

THIS_DIR = path.dirname(__file__)
VERSION_FILE = path.join(THIS_DIR, "VERSION")
Expand All @@ -23,17 +24,16 @@ def version_tuple(v):


def read_file_version():
f = open(VERSION_FILE)
v = f.readline()
f.close()
with open(VERSION_FILE) as f:
v = f.readline()
return v.strip()


def version():
try:
args = {"cwd": THIS_DIR}
devnull = open(os.devnull, "w")
p = Popen(["git", "describe"], stdout=PIPE, stderr=devnull, **args)
with open(os.devnull, "w") as devnull:
p = Popen(["git", "describe"], stdout=PIPE, stderr=devnull, **args)
out, err = p.communicate()
if p.returncode:
raise RuntimeError("no version defined?")
Expand All @@ -60,9 +60,9 @@ def compatible(v0, v1):
def write_version_file(v=None):
if v is None:
v = version()
f = open(VERSION_FILE, "w")
f.write(v)
f.close()
# with open(VERSION_FILE, "w") as f:
# f.write(v)
Path(VERSION_FILE).write_text(v)


VERSION = version()
Expand Down

0 comments on commit 285b576

Please sign in to comment.