Commit graph

13 commits

Author SHA1 Message Date
zaicruvoir1rominet
ca1f81f049
Avoid raising bare Exception (#1168)
* Keep old exception messages (avoid breaking-changes for users relying on exception messages)

* Move ``get_expected_str`` out of _exceptions.py, where it does not belong, to its own file in _parser/_parsing_check.py
2025-06-07 01:53:44 -07:00
Camillo
9f6e27600f
FullyQualifiedNameProvider: Optionally consider pyproject.toml files when determining a file's module name and package (#1148) 2024-06-12 10:36:50 +01:00
Mikhail Podtserkovskiy
497f7784c5
Fix: relative imports from '' package are not allowed (#894) 2023-03-14 15:07:40 -07:00
Amethyst Reese
f9536b522f
Pass root path to FullyQualifiedNameProvider (#867)
This allows FullyQualifiedNameProvider to work with absolute paths,
rather than assuming all paths given will be relative to the current
directory. This enables tools like Fixit to provide a root path, and
have the FullyQualifiedNameProvider correctly scope the final results
relative to that root path.

This does require that both the root path and the given file paths
match the other as relative or absolute, due to the
`calculate_module_and_package` helper comparing file paths relative
to the root path, but this seems like a reasonable tradeoff, and
unlikely to cause a problem in normal use cases.
2023-02-22 14:36:10 -08:00
Luke Petre
149599ee88
Restore the 0.4.1 behavior for libcst.helpers.get_absolute_module (#684) 2022-05-11 07:42:37 -04:00
Luke Petre
cf16eccea4
Update relative import logic to match cpython (#660)
* Always compute a module and package name

* Update name_provider to correctly support __main__ (also updated the tests to use data_provider)

* Update name_provider to correctly handle relative imports and package name

* Update relative module resolution to work on package names

* Use full_package_name in libcst.codemod.visitors.GatherImportsVisitor

* Use full_package_name in libcst.codemod.visitors.RemovedNodeVisitor

* Use full_package_name in libcst.codemod.visitors.AddImportsVisitor

* Fix failing test

* Fix typo in variable name

* PR feedback

* Force rebuild
2022-03-24 17:21:08 -04:00
Luke Petre
914b18339d
Support module and package names in the codemod context (#662)
* Support module and package names in the codemod context

* PR feedback

* Reorganize module name and relative name logic to libcst.helpers.module

* Force rebuild
2022-03-23 14:17:25 -04:00
Zsolt Dollenstein
d9a1dc8473
Fix all type errors (#579)
* bump pyre version
* make sure CI-pyre uses working copy
* remove unused pyre suppressions
* suppress invalid decorations
* fix undefined attributes
* fix missing return annotations
* fix tuple concatenation issues
* add native stubs
* fix invalid typing of **kwargs in test_apply_type_annotations
* only install pyre on non-windows
* update test fixture to reflect changes in recent pyre versions
* suppress errors related to mismatched positions
2022-01-05 18:13:01 +00:00
Zsolt Dollenstein
c44ff0500b
Fix license headers (#560)
* Facebook -> Meta

* remove year from doc copyright
2021-12-28 11:55:18 +00:00
jimmylai
c023fa7c4c
[typing] enable Pyre strict mode by default (#313)
Co-authored-by: Jimmy Lai <jimmylai@fb.com>
2020-06-12 18:24:18 -07:00
Jennifer Taylor
9bfc4faea9 Add documentation for libcst.codemod and friends. 2019-12-17 11:59:51 -08:00
Jennifer Taylor
f7e13df680 Apply correct copyright header to all open-sourced files. 2019-12-12 15:34:13 -08:00
Jennifer Taylor
f5c5f296fd Open-source a decent chunk of utility codemods that aren't instagram-specific. 2019-12-12 11:31:05 -08:00