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 project to python 3.11 and new linting #175

Merged
merged 2 commits into from
Oct 23, 2023

Conversation

ghukill
Copy link
Contributor

@ghukill ghukill commented Oct 20, 2023

What does this PR do?

  • bumps python version to 3.11
  • adds ruff and pyproject.toml approach to linting
  • code style and conventions updated to match new linting rules

Helpful background context

We are systematically moving through our python applications and updating the python version, linting configurations, and some other general scaffolding.

With this project likely touched for some upcoming projects, it was decided to update in advance of that work.

How can a reviewer manually see the effects of these changes?

Kickoff a new TIMDEX StepFunction run in Dev1 with the following input payload:

{
  "next-step": "extract",
  "run-date": "2023-10-20",
  "run-type": "daily",
  "source": "libguides",
  "oai-pmh-host": "https://libguides.mit.edu/oai.php",
  "oai-metadata-format": "oai_dc",
  "oai-set-spec": "guides"
}

Note the pipeline lambdas, which are invoked multiple times in the pipeline, are returning correctly formatted commands for the next pipeline step.

Or, view this run which was started after these changes were deployed to Dev1.

Includes new or updated dependencies?

YES

What are the relevant tickets?

https://mitlibraries.atlassian.net/browse/IN-894

Developer

  • All new ENV is documented in README
  • Stakeholder approval has been confirmed (or is not needed)

Code Reviewer

  • The commit message is clear and follows our guidelines
    (not just this pull request message)
  • There are appropriate tests covering any new functionality
  • The documentation has been updated or is unnecessary
  • The changes have been verified
  • New dependencies are appropriate or there were no changes

Why these changes are being introduced:

We are systematically moving through our python applications and updating the python version, linting configurations, and
some other general scaffolding.

With this project likely touched for some upcoming projects, it was decided to update in advance of that work.

How this addresses that need:

  * bumps python version to 3.11
  * adds ruff and pyproject.toml approach to linting
  * code style and conventions updated to match new linting rules

Side effects of this change:

The python version was updated from 3.10 to 3.11.  Tests have completed fine and testing will be performed in Dev1, but
majoy python versions always come with some risk of unintended changes.

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/IN-894
@github-actions
Copy link

Pull Request Test Coverage Report for Build 6590799247

  • 28 of 28 (100.0%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 4670455240: 0.0%
Covered Lines: 248
Relevant Lines: 248

💛 - Coveralls

Copy link
Contributor

@ehanson8 ehanson8 left a comment

Choose a reason for hiding this comment

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

Looks good! 2 comments

@@ -50,6 +49,8 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
cover/
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this correct or a coverage typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm, @jonavellecuerdo, any insights here? I took this from template verbatim, making sure anything important from the old file was maintained.

Copy link
Contributor

Choose a reason for hiding this comment

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

When creating the .dockerignore, I essentially copied contents of the existing .gitignore from the template repos. See note in PR for Python CLI template repo. So I think it should be fine!

@@ -6,7 +6,11 @@


def generate_extract_command(
input_data: dict, run_date: str, timdex_bucket: str, verbose: bool
# ruff: noqa: FBT001
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an interesting error code, I think we should consider respecting this with new apps but no need for refactoring here at the moment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which error code? The ruff linting rule FBT001?

Yeah, as we migrate projects, been seeing that. I can understand the logic behind not using positional boolean arguments in a function, but sometimes it does seem appropriate. As we ease into these new linting rules, I'm quite happy with this being an explicit skip for the time being when the situation calls for it, but not necessarily at the file or project level, because I do think it helps pause and think if a bool arg is a good idea.

@@ -7,7 +7,7 @@
logger = logging.getLogger(__name__)


def lambda_handler(event: dict, context: dict) -> dict: # noqa
def lambda_handler(event: dict, _context: dict) -> dict:
Copy link
Contributor

Choose a reason for hiding this comment

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

Was the underscore to address a linting error or preference? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes: because context is not used, it passes linting that way.

@jonavellecuerdo
Copy link
Contributor

@ghukill Thank you for updating this repo! Just one comment/question.

@ghukill ghukill merged commit 30a9fc6 into main Oct 23, 2023
3 checks passed
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.

None yet

3 participants