Skip to content

Commit 6db2137

Browse files
committedMay 5, 2022
all: apply staticcheck fixes
Signed-off-by: Sebastien Binet <binet@cern.ch>
1 parent ec3b7dc commit 6db2137

File tree

9 files changed

+45
-79
lines changed

9 files changed

+45
-79
lines changed
 

‎main.go

-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ import (
2121
_ "github.com/go-python/gpython/stdlib"
2222
)
2323

24-
// Globals
2524
var (
26-
// Flags
27-
debug = flag.Bool("d", false, "Print lots of debugging")
2825
cpuprofile = flag.String("cpuprofile", "", "Write cpu profile to file")
2926
)
3027

‎parser/lexer_test.go

+2-17
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ package parser
77
import (
88
"bytes"
99
"fmt"
10-
"log"
11-
"math"
1210
"testing"
1311

1412
"github.com/go-python/gpython/ast"
@@ -569,19 +567,6 @@ func TestLexerReadOperator(t *testing.T) {
569567
}
570568
}
571569

572-
// Whether two floats are more or less the same
573-
func approxEq(a, b float64) bool {
574-
log.Printf("ApproxEq(a = %#v, b = %#v)", a, b)
575-
diff := a - b
576-
log.Printf("ApproxEq(diff = %e)", diff)
577-
if math.Abs(diff) > 1e-10 {
578-
log.Printf("ApproxEq(false)")
579-
return false
580-
}
581-
log.Printf("ApproxEq(true)")
582-
return true
583-
}
584-
585570
func TestLexerReadNumber(t *testing.T) {
586571
x := yyLex{}
587572
for _, test := range []struct {
@@ -710,10 +695,10 @@ func TestLexerReadString(t *testing.T) {
710695
if testValueBytes, ok := test.value.(py.Bytes); !ok {
711696
t.Error("Expecting py.Bytes")
712697
} else {
713-
equal = (bytes.Compare(valueBytes, testValueBytes) == 0)
698+
equal = bytes.Equal(valueBytes, testValueBytes)
714699
}
715700
} else {
716-
equal = (value == test.value)
701+
equal = value == test.value
717702
}
718703

719704
if token != test.token || !equal || x.line != test.out {

‎py/complex.go

-7
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,6 @@ func complexFloor(a Complex) Complex {
152152
return Complex(complex(math.Floor(real(a)), math.Floor(imag(a))))
153153
}
154154

155-
// Floor divide two complex numbers
156-
func complexFloorDiv(a, b Complex) Complex {
157-
q := complexFloor(a / b)
158-
r := a - q*b
159-
return Complex(r)
160-
}
161-
162155
func (a Complex) M__floordiv__(other Object) (Object, error) {
163156
if b, ok := convertToComplex(other); ok {
164157
return complexFloor(a / b), nil

‎py/import.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ func XImportModuleLevelObject(ctx Context, nameObj, given_globals, locals, given
272272
if err != nil {
273273
return nil, err
274274
}
275-
} else {
275+
// } else { // not initializing
276276
// FIXME locking
277277
// if _PyImport_ReleaseLock() < 0 {
278278
// return nil, ExceptionNewf(RuntimeError, "not holding the import lock")

‎py/type.go

+28-28
Original file line numberDiff line numberDiff line change
@@ -570,14 +570,14 @@ func lookup_maybe(self Object, attr string) Object {
570570
return res
571571
}
572572

573-
func lookup_method(self Object, attr string) Object {
574-
res := lookup_maybe(self, attr)
575-
if res == nil {
576-
// FIXME PyErr_SetObject(PyExc_AttributeError, attrid->object);
577-
return ExceptionNewf(AttributeError, "'%s' object has no attribute '%s'", self.Type().Name, attr)
578-
}
579-
return res
580-
}
573+
// func lookup_method(self Object, attr string) Object {
574+
// res := lookup_maybe(self, attr)
575+
// if res == nil {
576+
// // FIXME PyErr_SetObject(PyExc_AttributeError, attrid->object);
577+
// return ExceptionNewf(AttributeError, "'%s' object has no attribute '%s'", self.Type().Name, attr)
578+
// }
579+
// return res
580+
// }
581581

582582
// Method resolution order algorithm C3 described in
583583
// "A Monotonic Superclass Linearization for Dylan",
@@ -955,26 +955,26 @@ func add_subclass(base, t *Type) {
955955
// return result;
956956
}
957957

958-
func remove_subclass(base, t *Type) {
959-
// Py_ssize_t i;
960-
// PyObject *list, *ref;
961-
962-
// list = base->tp_subclasses;
963-
// if (list == nil) {
964-
// return;
965-
// }
966-
// assert(PyList_Check(list));
967-
// i = PyList_GET_SIZE(list);
968-
// while (--i >= 0) {
969-
// ref = PyList_GET_ITEM(list, i);
970-
// assert(PyWeakref_CheckRef(ref));
971-
// if (PyWeakref_GET_OBJECT(ref) == (PyObject*)type) {
972-
// /* this can't fail, right? */
973-
// PySequence_DelItem(list, i);
974-
// return;
975-
// }
976-
// }
977-
}
958+
// func remove_subclass(base, t *Type) {
959+
// // Py_ssize_t i;
960+
// // PyObject *list, *ref;
961+
//
962+
// // list = base->tp_subclasses;
963+
// // if (list == nil) {
964+
// // return;
965+
// // }
966+
// // assert(PyList_Check(list));
967+
// // i = PyList_GET_SIZE(list);
968+
// // while (--i >= 0) {
969+
// // ref = PyList_GET_ITEM(list, i);
970+
// // assert(PyWeakref_CheckRef(ref));
971+
// // if (PyWeakref_GET_OBJECT(ref) == (PyObject*)type) {
972+
// // /* this can't fail, right? */
973+
// // PySequence_DelItem(list, i);
974+
// // return;
975+
// // }
976+
// // }
977+
// }
978978

979979
// Ready the type for use
980980
//

‎py/zip.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ type Zip struct {
1010
size int
1111
}
1212

13-
// A python ZipIterator iterator
14-
type ZipIterator struct {
15-
zip Zip
16-
}
13+
// // A python ZipIterator iterator
14+
// type ZipIterator struct {
15+
// zip Zip
16+
// }
1717

1818
var ZipType = NewTypeX("zip", `zip(iter1 [,iter2 [...]]) --> zip object
1919

‎repl/cli/cli.go

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"os/user"
1313
"path/filepath"
1414

15-
"github.com/go-python/gpython/py"
1615
"github.com/go-python/gpython/repl"
1716
"github.com/peterh/liner"
1817
)
@@ -36,7 +35,6 @@ type readline struct {
3635
*liner.State
3736
repl *repl.REPL
3837
historyFile string
39-
module *py.Module
4038
prompt string
4139
}
4240

‎stdlib/math/math.go

-7
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,6 @@ var (
7575
ERANGE = py.ExceptionNewf(py.OverflowError, "math range error")
7676
)
7777

78-
// panic if ok is false
79-
func assert(ok bool) {
80-
if !ok {
81-
panic("assertion failed")
82-
}
83-
}
84-
8578
// isFinite is true if x is not Nan or +/-Inf
8679
func isFinite(x float64) bool {
8780
return !(math.IsInf(x, 0) || math.IsNaN(x))

‎stdlib/sys/sys.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,10 @@ func sys_setrecursionlimit(self py.Object, args py.Tuple) (py.Object, error) {
347347
return nil, py.NotImplementedError
348348
}
349349

350-
const hash_info_doc = `hash_info
351-
352-
A struct sequence providing parameters used for computing
353-
numeric hashes. The attributes are read only.`
350+
// const hash_info_doc = `hash_info
351+
//
352+
// A struct sequence providing parameters used for computing
353+
// numeric hashes. The attributes are read only.`
354354

355355
// PyStructSequence_Field hash_info_fields[] = {
356356
// {"width", "width of the type used for hashing, in bits"},
@@ -539,9 +539,9 @@ func sys_clear_type_cache(self py.Object, args py.Tuple) (py.Object, error) {
539539
return nil, py.NotImplementedError
540540
}
541541

542-
const flags__doc__ = `sys.flags
543-
544-
Flags provided through command line arguments or environment vars.`
542+
// const flags__doc__ = `sys.flags
543+
//
544+
// Flags provided through command line arguments or environment vars.`
545545

546546
// PyTypeObject FlagsType;
547547

@@ -603,9 +603,9 @@ Flags provided through command line arguments or environment vars.`
603603
// return seq;
604604
// }
605605

606-
const version_info__doc__ = `sys.version_info
607-
608-
Version information as a named tuple.`
606+
//const version_info__doc__ = `sys.version_info
607+
//
608+
//Version information as a named tuple.`
609609

610610
// PyStructSequence_Field version_info_fields[] = {
611611
// {"major", "Major release number"},

0 commit comments

Comments
 (0)
Please sign in to comment.