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

Update, general cleanup and overall improvements #35

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

Conversation

rbroderi
Copy link

@rbroderi rbroderi commented May 1, 2022

Update to python 3
Utilize beartype for runtime O(1) typechecking
Add type hints for mypy / beartype static type checking.
Update license to GPL v3

@case case mentioned this pull request May 4, 2022
Copy link

@MatthijsBurgh MatthijsBurgh left a comment

Choose a reason for hiding this comment

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

Why the archives?
Why the released version zips? These should go in the releases.
I think docs should go in a gh-pages branch

@@ -0,0 +1,41 @@
# This is a basic workflow to help you get started with Actions

Choose a reason for hiding this comment

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

I would remove all the comments. When people don't understand the file, they should look at the GH documentation.

Comment on lines 6 to 14
on: # yamllint disable-line rule:truthy
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [master]
pull_request:
branches: [master]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Choose a reason for hiding this comment

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

Allow pushes/pr to all branches. Enough capacity to check everything.

Suggested change
on: # yamllint disable-line rule:truthy
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [master]
pull_request:
branches: [master]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
on: [push, pull_request, workflow_dispatch]

run: python --version
- name: Install dependencies
run: |
python -m pip install --upgrade pip

Choose a reason for hiding this comment

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

No need to update pip

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3

Choose a reason for hiding this comment

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

Use v4

strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10']

Choose a reason for hiding this comment

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

Extend to use 3.11 too

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE

Choose a reason for hiding this comment

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

Just rename to LICENSE.txt

LICENSE.txt Outdated
@@ -0,0 +1,39 @@
Verbal Expressions

Choose a reason for hiding this comment

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

Why two licenses?

@@ -1,25 +1,34 @@
PythonVerbalExpressions
=======================
Verbex: Python verbal based regular expressions

Choose a reason for hiding this comment

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

Suggested change
Verbex: Python verbal based regular expressions
# Verbex: Python verbal based regular expressions
[![CI](https://github.com/VerbalExpressions/PythonVerbalExpressions/actions/workflows/main.yml/badge.svg)](https://github.com/VerbalExpressions/PythonVerbalExpressions/actions/workflows/main.yml)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
[![PyPI license](https://img.shields.io/pypi/l/verbex)](https://www.gnu.org/licenses/gpl-3.0.en.html)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/verbex)](https://pypi.python.org/pypi/ansicolortags/)
[![Generic badge](https://img.shields.io/badge/mypy-typed-purple.svg)](http://mypy-lang.org/)
[![Generic badge](https://img.shields.io/badge/beartype-runtime_typed-cyan.svg)](https://github.com/beartype/beartype)
[![Generic badge](https://img.shields.io/badge/bandit-checked-magenta.svg)](https://bandit.readthedocs.io/en/latest/)
[![Generic badge](https://img.shields.io/badge/flake8-linted-yellow.svg)](https://github.com/pycqa/flake8)
## Installation
```bash
pip install Verbex

Usage

from verbex import Verbex
verbex = Verbex()

Documentation

API

Examples

Testing if we have a valid URL

# Create an example of how to test for correctly formed URLs
verbex = Verbex()
tester = (verbex.
            start_of_line().
            find('http').
            maybe('s').
            find('://').
            maybe('www.').
            anything_but(' ').
            end_of_line()
)

# Create an example URL
test_url = "https://www.google.com"

# Test if the URL is valid
if re.match(test_url.regex,test_url):
    print("Valid URL")

# Print the generated regex
print(tester) # => ^(http)(s)?(\:\/\/)(www\.)?([^\ ]*)$

Replacing strings

# Create a test string
replace_me = "Replace bird with a duck"

# Create an expression that looks for the word "bird"
expression = Verbex().find('bird')

# Compile and use the regular expression using re
import re
regexp = expression.compile()
result_re = regexp.sub('duck', replace_me)
print(result_re)

Developer setup : running the tests

python setup.py develop
python setup.py test

Other implementations

You can view all implementations on VerbalExpressions.github.io

Choose a reason for hiding this comment

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

This suggestion is a bit shitty...

@@ -0,0 +1,10 @@
try:

Choose a reason for hiding this comment

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

I am not sure we should rename the library

verbex/verbex.py Outdated
@@ -0,0 +1,646 @@
"""Generate regular expressions from an easier fluent verbal form."""

Choose a reason for hiding this comment

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

By renaming the library, the entire diff is gone.

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.

2 participants