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

python.2: fix tests, use source checkers and more python3 features #665

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -971,13 +971,10 @@ python stepX_YYY.py

### Python.2 (3.X)

The second Python implementation makes heavy use of type annotations and uses the Arpeggio parser library.

```
# Recommended: do these steps in a Python virtual environment.
pip3 install Arpeggio==1.9.0
python3 stepX_YYY.py
```
The second Python implementation is checked for style and types
(flake8, pylint, mypy). It reports all errors with details.
It demonstrates iterators, decorators, functional tools, chain maps,
dataclasses, introspection, match statements, assignement expressions.

### RPython

Expand Down
18 changes: 5 additions & 13 deletions impls/python.2/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:bionic
FROM ubuntu:24.04
MAINTAINER Joel Martin <[email protected]>

##########################################################
Expand All @@ -9,10 +9,8 @@ MAINTAINER Joel Martin <[email protected]>
RUN apt-get -y update

# Required for running tests
RUN apt-get -y install make python

# Some typical implementation and test requirements
RUN apt-get -y install curl libreadline-dev libedit-dev
RUN apt-get -y install make python3
RUN ln -fs /usr/bin/python3 /usr/local/bin/python

RUN mkdir -p /mal
WORKDIR /mal
Expand All @@ -21,11 +19,5 @@ WORKDIR /mal
# Specific implementation requirements
##########################################################

# Nothing additional needed for python
RUN apt-get -y install python3

# For dist packaging
RUN apt-get -y install zip

# Pypi modules
RUN apt-get -y install python3-pip && pip3 install Arpeggio==1.9.0
# For checking:
# RUN apt-get -y install flake8 mypy pylint
24 changes: 22 additions & 2 deletions impls/python.2/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
# make check sources=reader.py may be convenient
sources ?= *.py

f8 += D100 # Missing docstring in public module
f8 += D101 # Missing docstring in public class
f8 += D102 # Missing docstring in public method
f8 += D103 # Missing docstring in public function
f8 += D105 # Missing docstring in magic method
f8 += D107 # Missing docstring in __init__
f8 += I100 # order of import statements (incompatible with pylint)
f8 += W503 # line break before binary operator (incompatible with 504)
pl += missing-module-docstring
pl += missing-class-docstring
pl += missing-function-docstring
pl += R0801 # Similar lines in 2 files (steps...)

all:
true

.PHONY: clean
check:
pylint --disable=$(shell echo $(pl) | sed 's/ /,/g') $(sources)
mypy $(sources)
flake8 --ignore=$(shell echo $(f8) | sed 's/ /,/g') $(sources)

clean:
rm -f *~
rm -fr __pycache__/ .mypy_cache/
Loading
Loading