Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codechange: Vendor in latest ply version #342

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

glx22
Copy link
Contributor

@glx22 glx22 commented Oct 14, 2024

According to https://github.com/dabeaz/ply/blob/master/CHANGES, the latest version will never be available via pip, and the preferred way to use ply is to vendor it.
Latest ply version removes caching of lexer/parser tables, and as a side effect fixes #332.

import sys
import types
import copy
import os

Check notice

Code scanning / CodeQL

Unused import Note

Import of 'os' is not used.
return

if not tokens:
self.log.error('tokens is empty')

Check warning

Code scanning / CodeQL

Unreachable code Warning

This statement is unreachable.
module = inspect.getmodule(f)
self.modules.add(module)

tokname = self.toknames[fname]

Check warning

Code scanning / CodeQL

Variable defined multiple times Warning

This assignment to 'tokname' is unnecessary as it is
redefined
before this value is used.
global lexer

ldict = None
stateinfo = {'INITIAL': 'inclusive'}

Check warning

Code scanning / CodeQL

Variable defined multiple times Warning

This assignment to 'stateinfo' is unnecessary as it is
redefined
before this value is used.
# Create global versions of the token() and input() functions
token = lexobj.token
input = lexobj.input
lexer = lexobj

Check notice

Code scanning / CodeQL

Unused global variable Note

The global variable 'lexer' is not used.
for f in self.pfuncs:
if f[3]:
parts.append(f[3])
except (TypeError, ValueError):

Check notice

Code scanning / CodeQL

Empty except Note

'except' clause does nothing but pass and there is no explanatory comment.
return

if not tokens:
self.log.error('tokens is empty')

Check warning

Code scanning / CodeQL

Unreachable code Warning

This statement is unreachable.
if doc[1] == ':':
self.log.warning('%s:%d: Possible grammar rule %r defined without p_ prefix',
v.__code__.co_filename, v.__code__.co_firstlineno, n)
except IndexError:

Check notice

Code scanning / CodeQL

Empty except Note

'except' clause does nothing but pass and there is no explanatory comment.
if debuglog is None:
if debug:
try:
debuglog = PlyLogger(open(debugfile, 'w'))

Check warning

Code scanning / CodeQL

File is not always closed Warning

File is opened but is not closed.
lr.bind_callables(pinfo.pdict)
parser = LRParser(lr, pinfo.error_func)

parse = parser.parse

Check notice

Code scanning / CodeQL

Unused global variable Note

The global variable 'parse' is not used.
@LordAro
Copy link
Member

LordAro commented Oct 14, 2024

Given it removes commandline options, this feels like more than just a "Codechange"

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.

Bug: const keyword not working
2 participants