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

Let LocalFileLinter reuse the Dependency instead falling back on its path #3586

Closed
wants to merge 20 commits into from

Conversation

JCZuurmond
Copy link
Member

Changes

Let LocalFileLinter reuse the Dependency instead falling back on its path as we introduce duplicate ways of loading files.

In addition to that, the PR contains a clean up of:

  • Moving non-linting file classes from source_code/linters/files.py to source_code/files.py to avoid circular imports
  • Extend MockPathLookup to verify which paths are resolved
  • Make current_session public on LinterContext for reuse instead of passing it next to the LinterContext
  • Improve testing and handling corner cases for FileLoader

Linked issues

Progresses #3514
Breaks up #3520

Functionality

  • modified existing command: databricks labs ucx migrate-local-code

Tests

  • manually tested
  • modified and added unit tests
  • modified and added integration tests

@JCZuurmond JCZuurmond added migrate/code Abstract Syntax Trees and other dark magic migrate/python Pull requests that update Python code python Pull requests that update Python code internal this pull request won't appear in release notes labels Jan 29, 2025
@JCZuurmond JCZuurmond self-assigned this Jan 29, 2025
@JCZuurmond JCZuurmond requested a review from a team as a code owner January 29, 2025 16:32
Copy link

github-actions bot commented Jan 29, 2025

✅ 57/57 passed, 2 skipped, 25m39s total

Running from acceptance #8171

@JCZuurmond JCZuurmond force-pushed the fix/update-file-linter-signature branch from 7447e12 to c58925d Compare January 31, 2025 08:37
problems[idx] = dataclasses.replace(problem, source_path=self._path)
return problems
# supported language that does not generate dependencies
if self.language == Language.SQL:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we combine this and the other return as SQL is also unsupported and probably doesn't need an if statement

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer to keep it like this because SQL is supported, it just does not return a dependency graph, see #3639

Copy link
Contributor

@pritishpai pritishpai left a comment

Choose a reason for hiding this comment

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

Commented a few nits. Approving so that you can merge in the AM.

@JCZuurmond
Copy link
Member Author

Surpassed by #3641

@JCZuurmond JCZuurmond closed this Feb 5, 2025
github-merge-queue bot pushed a commit that referenced this pull request Feb 5, 2025
## Changes
Use `Language` on `LocalFile`, not `CellLanguage`, as a file might
consist of cells when it is a notebook, but the file language is not a
cell language

### Linked issues

Breaks up #3586

### Functionality

- [x] rewrote code linting related resources

### Tests
- [x] Added tests for `LocalFile`
github-merge-queue bot pushed a commit that referenced this pull request Feb 5, 2025
…t from the context (#3638)

<!-- REMOVE IRRELEVANT COMMENTS BEFORE CREATING A PULL REQUEST -->
## Changes
Make session state public on `LinterContext` and access it from the
context instead of passing it along.

### Linked issues

Breaks up #3586

### Functionality

- [x] rewrote code linting related resources

### Tests
- [x] Reusing existing tests
github-merge-queue bot pushed a commit that referenced this pull request Feb 5, 2025
## Changes
Improve file handling by `FileLoader`:
- Verify the `FileLoader` resolves files using the `PathLookup`
- Handle file opening errors, like `PermissionError`,
`FileNotFoundError`
- Handle file with BOM encodings
- Handle empty files

### Linked issues

Breaks up #3586

### Functionality

- [x] rewrote code linting related resources

### Tests
- [x] Added tests for `FileLoader`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal this pull request won't appear in release notes migrate/code Abstract Syntax Trees and other dark magic migrate/python Pull requests that update Python code pr/do-not-merge this pull request is not ready to merge python Pull requests that update Python code
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants