-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
python: Switch to pyproject.toml #290
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
07cb344
Switch to pyproject.toml
youtux afbba91
Remove `bin/` dir, use scripts as `python -m ...`
youtux f1cd4e1
Undo mistakenly committed change
youtux 1c5114c
Add changelog line
youtux b94911b
Move scripts out of the `gherkin` package.
youtux 5405b62
Do not use `raise SystemExit`
youtux 9f7f9cc
No need to specify package-data, as it's collected by default when us…
youtux d992ac4
Fix package find patterns (match the gherkin package, and every packa…
youtux 987e836
Delete leftover `MANIFEST`, which is not necessary anymore
youtux dc520a1
Remove `scripts/__init__.py`, as it doesn't need to be a package
youtux 3ed84b3
Rename `scripts/gherkin.py` to avoid potentiall collisions with `gher…
youtux 58bef75
Remove unused import
youtux 4a9d3b1
CHANGELOG: Add mention of pull #290 for Python change.
jenisys File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from optparse import OptionParser | ||
import json | ||
|
||
from gherkin.stream.gherkin_events import GherkinEvents | ||
from gherkin.stream.source_events import SourceEvents | ||
|
||
|
||
def create_arg_parser() -> OptionParser: | ||
parser = OptionParser() | ||
parser.add_option( | ||
"--no-source", | ||
action="store_false", | ||
dest="print_source", | ||
default=True, | ||
help="don't print source events", | ||
) | ||
parser.add_option( | ||
"--no-ast", | ||
action="store_false", | ||
dest="print_ast", | ||
default=True, | ||
help="don't print ast events", | ||
) | ||
parser.add_option( | ||
"--no-pickles", | ||
action="store_false", | ||
dest="print_pickles", | ||
default=True, | ||
help="don't print pickle events", | ||
) | ||
return parser | ||
|
||
|
||
def main() -> None: | ||
arg_parser = create_arg_parser() | ||
|
||
options, args = arg_parser.parse_args() | ||
|
||
source_events = SourceEvents(args) | ||
gherkin_events = GherkinEvents( | ||
GherkinEvents.Options( | ||
print_source=options.print_source, | ||
print_ast=options.print_ast, | ||
print_pickles=options.print_pickles, | ||
) | ||
) | ||
|
||
for source_event in source_events.enum(): | ||
for event in gherkin_events.enum(source_event): | ||
print(json.dumps(event)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import sys | ||
|
||
from gherkin.token_scanner import TokenScanner | ||
from gherkin.token_formatter_builder import TokenFormatterBuilder | ||
from gherkin.parser import Parser | ||
|
||
|
||
def main() -> None: | ||
files = sys.argv[1:] | ||
parser = Parser(TokenFormatterBuilder()) | ||
for file in files: | ||
scanner = TokenScanner(file) | ||
print(parser.parse(scanner)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BAD IDEA: Removing the scripts from the package description
gherkin/__main__.py
should be kept because that is the natural choice for the main programThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, I'm even more inclined to not include the
scripts/
folder in the distribution at all.The reason is that these scripts are only used internally, as there is absolutely no API or documentation about these. Hell, I can't even figure out what the
gherkin
script does at all, since there is no documentation.I really doubt that any downstream user is using these. If anything, we are just polluting their PATH with this irrelevant
gherkin
executable.In the remote hypothesis that a downstream user was relying on this, we can always release a hotfix with the script included in the distribution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the executable is needed for the purposes of the user to understand how to run main, wouldn't this be better handled with documentation?
I may have missed something, but I didn't use this executable or use it to understand how to use gherkin when I implemented it in pytest-bdd. I'm not entirely sure how useful it for including downstream from personal experience, unless I've missed a point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these scripts/executables are only for internal use, then why put them in the Python package and not put the in
bin/
directory where they were before (at least one of them).In addition, the
gherkin
script is provided in the current package version and before. Therefore, the script was part of the “API” of this package. By removing them you basically break this API in the next version. And you should be aware of that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can put them out of the
gherkin
package, so that they will automatically be out of the distributed package.yes I know, but every release is a major release it seems, so semver semantics allow this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in b94911b