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

Add python support #121

Merged
merged 5 commits into from
May 23, 2024
Merged

Conversation

bogdancondorachi
Copy link
Contributor

@bogdancondorachi bogdancondorachi commented May 15, 2024

@brendt As the title suggests this PR adds Python language support :)

📋 TODO:

image

@bogdancondorachi bogdancondorachi force-pushed the python-language branch 4 times, most recently from 6d0ed00 to 235b150 Compare May 15, 2024 21:07
Comment on lines +15 to +22
public function __construct(private array $keywords = [
'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue',
'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global',
'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass',
'raise', 'return', 'try', 'while', 'with', 'yield',
])
{
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I chose to add the keywords as an array directly within the class constructor for simplicity. For me this offers more efficiency and clarity, especially considering that the list of keywords is unlikely to change frequently.

Comment on lines +15 to +27
public function __construct(private array $builtinFunctions = [
'__import__', 'abs', 'aiter', 'all', 'any', 'anext', 'ascii', 'bin', 'bool',
'breakpoint', 'bytearray', 'bytes', 'callable', 'chr', 'classmethod', 'compile',
'complex', 'delattr', 'dict', 'dir', 'divmod', 'enumerate', 'eval', 'exec',
'filter', 'float', 'format', 'frozenset', 'getattr', 'globals', 'hasattr',
'hash', 'help', 'hex', 'id', 'input', 'int', 'isinstance', 'issubclass', 'iter',
'len', 'list', 'locals', 'map', 'max', 'memoryview', 'min', 'next', 'object',
'oct', 'open', 'ord', 'pow', 'print', 'property', 'range', 'repr', 'reversed',
'round', 'set', 'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum',
'super', 'tuple', 'type', 'vars', 'zip',
])
{
}
Copy link
Contributor Author

@bogdancondorachi bogdancondorachi May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same goes for the built-in functions, adding all of this individually inside the PythonLanguage just gave me anxiety 😂

@bogdancondorachi bogdancondorachi force-pushed the python-language branch 2 times, most recently from 14bd226 to 9f53a1e Compare May 16, 2024 22:14
@coveralls
Copy link

coveralls commented May 16, 2024

Pull Request Test Coverage Report for Build 9206970052

Details

  • 47 of 51 (92.16%) changed or added relevant lines in 14 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 95.326%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/Languages/Python/Patterns/PyBooleanPattern.php 1 2 50.0%
src/Languages/Python/Patterns/PyClassNamePattern.php 1 2 50.0%
src/Languages/Python/Patterns/PyDecoratorPattern.php 1 2 50.0%
src/Languages/Python/Patterns/PyTripleSingleQuoteStringPattern.php 1 2 50.0%
Totals Coverage Status
Change from base Build 9206715453: -0.1%
Covered Lines: 1550
Relevant Lines: 1626

💛 - Coveralls

@bogdancondorachi bogdancondorachi marked this pull request as ready for review May 16, 2024 22:18
@bogdancondorachi bogdancondorachi marked this pull request as draft May 17, 2024 06:30
@bogdancondorachi
Copy link
Contributor Author

Ok @brendt, I will flag this as ready for review. I think it covers well most of the basic stuff to be considered usable.

I'll defiantly continue into more edge cases and additional patterns but for now I'll leave that for a later update.

@bogdancondorachi bogdancondorachi marked this pull request as ready for review May 17, 2024 06:49
@brendt
Copy link
Member

brendt commented May 22, 2024

Cool!

I'll defiantly continue into more edge cases and additional patterns but for now I'll leave that for a later update.

I agree, this can be finetuned later :) Are you on discord, by any chance? We have a server for Tempest related stuff, it would be nice if I could ping you there — I don't expect you to put in any work you don't want to, but I lack Python knowledge, so it'd be nice to bounce ideas off of someone if we need to further work on this: https://discord.gg/pPhpTGUMPQ

Also, shall I wait until #123 gets merged and you can update this PR accordingly?

@brendt
Copy link
Member

brendt commented May 23, 2024

FYI #123 has been merged :)

@bogdancondorachi
Copy link
Contributor Author

@brendt Added NUMBER and BOOLEAN support. This can be merged now. I'll continue to improve on it when I find time but for now, it should cover enough to be usable.

@brendt brendt merged commit a38bed6 into tempestphp:main May 23, 2024
4 checks passed
@bogdancondorachi bogdancondorachi deleted the python-language branch May 23, 2024 11:26
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.

3 participants