Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CICD 2022
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arthur Jacquin
CICD 2022
Commits
551d3ed4
Commit
551d3ed4
authored
Oct 13, 2022
by
Arthur Jacquin
Browse files
Options
Downloads
Patches
Plain Diff
fix: fix the calculator
parent
0f47a881
No related branches found
No related tags found
No related merge requests found
Pipeline
#46378
failed
Oct 13, 2022
Stage: dependencies
Stage: lint
Stage: test
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitlab-ci.yml
+10
-3
10 additions, 3 deletions
.gitlab-ci.yml
calculator/calculator.py
+2
-2
2 additions, 2 deletions
calculator/calculator.py
calculator/operators.py
+3
-1
3 additions, 1 deletion
calculator/operators.py
with
15 additions
and
6 deletions
.gitlab-ci.yml
+
10
−
3
View file @
551d3ed4
...
...
@@ -10,7 +10,7 @@ download_dependencies:
script
:
-
python -m venv .venv
-
source .venv/bin/activate
-
pip install -r requirements.txt
-
python -m
pip install -r requirements.txt
artifacts
:
paths
:
-
.venv
...
...
@@ -23,9 +23,16 @@ pylint:
-
download_dependencies
script
:
-
source .venv/bin/activate
-
pip install pylint
-
pylint calculator --fail-on=error
-
python -m
pip install pylint
-
python -m
pylint calculator --fail-on=error
# À toi de nous rajouter un petit job pour faire des tests unitaires
pytest
:
## Bon courage
stage
:
test
dependencies
:
-
download_dependencies
script
:
-
source .venv/bin/activate
-
python -m pip install pylint
-
python -m pytest calculator
\ No newline at end of file
This diff is collapsed.
Click to expand it.
calculator/calculator.py
+
2
−
2
View file @
551d3ed4
...
...
@@ -66,5 +66,5 @@ class Calculator:
return
OperatorExpression
(
operator
,
self
.
parse
(
left
),
self
.
parse
(
right
))
def
__call__
(
self
,
expression
:
str
)
->
Term
:
return
5
# Au moins il y a pas de surprise 😐
#
return self.parse(self.tokenize(expression))()
#
return 5 # Au moins il y a pas de surprise 😐
return
self
.
parse
(
self
.
tokenize
(
expression
))()
This diff is collapsed.
Click to expand it.
calculator/operators.py
+
3
−
1
View file @
551d3ed4
"""
Operator module contains the Operator class and a list of standard operators.
"""
class
Operator
:
"""
Operator class is a binary operator with a symbol, a precedence and an evaluation function.
...
...
@@ -21,6 +23,6 @@ class Operator:
STANDARD_OPERATORS
=
{
'
+
'
:
Operator
(
'
+
'
,
1
,
lambda
a
,
b
:
a
+
b
),
'
-
'
:
Operator
(
'
-
'
,
1
,
lambda
a
,
b
:
a
-
b
),
'
*
'
:
Operator
(
'
×
'
,
2
,
lambda
a
,
b
:
a
*
b
),
'
*
'
:
Operator
(
'
*
'
,
2
,
lambda
a
,
b
:
a
*
b
),
'
/
'
:
Operator
(
'
/
'
,
2
,
lambda
a
,
b
:
a
/
b
),
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment