Skip to content

Commit

Permalink
Change class methods to static where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
renatahodovan committed Feb 24, 2020
1 parent 06ab3c0 commit da24ffe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion grammarinator/model/default_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

class DefaultModel(object):

def random_decision(self):
@staticmethod
def random_decision():
return bool(random.getrandbits(1))

def choice(self, name, choices):
Expand Down
14 changes: 9 additions & 5 deletions grammarinator/runtime/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,18 @@ def create_node(self, node):
self.root = self.root or node
return node

def char_from_list(self, options):
@staticmethod
def char_from_list(options):
return chr(random.choice(options))

def any_ascii_char(self):
@staticmethod
def any_ascii_char():
return random.choice(string.printable)

def any_unicode_char(self):
return self.char_from_list(printable_unicode_chars)
@staticmethod
def any_unicode_char():
return Generator.char_from_list(printable_unicode_chars)

def any_ascii_letter(self):
@staticmethod
def any_ascii_letter():
return random.choice(string.ascii_letters)

0 comments on commit da24ffe

Please sign in to comment.